reindented all of the code using uncrustify
authorØyvind Kolås <ok@src.gnome.org>
Sun, 25 Mar 2007 21:44:16 +0000 (21:44 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Sun, 25 Mar 2007 21:44:16 +0000 (21:44 +0000)
svn path=/trunk/; revision=233

49 files changed:
ChangeLog
babl/babl-component.c
babl/babl-conversion.c
babl/babl-core.c
babl/babl-db.c
babl/babl-extension.c
babl/babl-fish-path.c
babl/babl-fish-reference.c
babl/babl-fish-simple.c
babl/babl-fish-stats.c
babl/babl-fish.c
babl/babl-format.c
babl/babl-image.c
babl/babl-internal.c
babl/babl-introspect.c
babl/babl-memory.c
babl/babl-model.c
babl/babl-sampling.c
babl/babl-sanity.c
babl/babl-type.c
babl/babl-util.c
babl/babl.c
babl/base/babl-base.c
babl/base/formats.c
babl/base/model-cmyk.c
babl/base/model-gray.c
babl/base/model-rgb.c
babl/base/model-ycbcr.c
babl/base/type-float.c
babl/base/type-u16.c
babl/base/type-u32.c
babl/base/type-u8.c
babl/gettimeofday.c
extensions/CIE-Lab.c
extensions/gegl-fixups.c
extensions/gggl-lies.c
extensions/gggl.c
extensions/naive-CMYK.c
tests/babl-html-dump.c
tests/babl_class_name.c
tests/babl_fish_path_fitness.c
tests/conversions.c
tests/formats.c
tests/grayscale_to_rgb.c
tests/models.c
tests/rgb_to_bgr.c
tests/rgb_to_ycbcr.c
tests/srgb_to_lab_u8.c
tests/types.c

index d582eccc06300e1220137e42368bd124c0489ec3..d3671a9d0a77a4017a4de79bf647dfa690edb6f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-03-21  Øyvind Kolås  <pippin@gimp.org>
+
+       Reindented all of the code using uncrustify.
+
 2007-03-21  Øyvind Kolås  <pippin@gimp.org>
 
        * configure.ac: Make force the value of shrext to either .dll or .so
 
 2007-01-06  Michael Schumacher  <schumaml@cvs.gnome.org>
 
-        This change makes babl buildable on Windows.
+       This change makes babl buildable on Windows.
        
        * configure.ac: Add a check for function dlopen and disabled
        static libs by default. Check for gettimeofday by using
index 8e87589663df7896aa4e334cebb955edea88bb95..4b4e30da753ec8b5c8a9173fa577c3408f0eede3 100644 (file)
@@ -24,7 +24,7 @@
 #include <stdarg.h>
 
 
-static int 
+static int
 each_babl_component_destroy (Babl *babl,
                              void *data)
 {
@@ -41,8 +41,8 @@ component_new (const char *name,
 {
   Babl *babl;
 
-  babl                   = babl_malloc (sizeof (BablComponent) + strlen (name) + 1);
-  babl->instance.name    = (char *) babl + sizeof (BablComponent);
+  babl                = babl_malloc (sizeof (BablComponent) + strlen (name) + 1);
+  babl->instance.name = (char *) babl + sizeof (BablComponent);
   strcpy (babl->instance.name, name);
 
   babl->class_type       = BABL_COMPONENT;
@@ -59,24 +59,24 @@ babl_component_new (void *first_arg,
 {
   va_list     varg;
   Babl       *babl;
-  int         id         = 0;
-  int         luma    = 0;
-  int         chroma  = 0;
-  int         alpha   = 0;
-  const char *arg=(char*)first_arg;
+  int         id     = 0;
+  int         luma   = 0;
+  int         chroma = 0;
+  int         alpha  = 0;
+  const char *arg    = (char *) first_arg;
 
   va_start (varg, first_arg);
-  
+
   while (1)
     {
       arg = va_arg (varg, char *);
       if (!arg)
         break;
-      
+
       if (BABL_IS_BABL (arg))
         {
 #ifdef BABL_LOG
-          Babl *babl = (Babl*) arg;
+          Babl *babl = (Babl *) arg;
           babl_log ("%s unexpected", babl_class_name (babl->class_type));
 #endif
         }
@@ -86,12 +86,12 @@ babl_component_new (void *first_arg,
         {
           id = va_arg (varg, int);
         }
-      
+
       else if (!strcmp (arg, "luma"))
         {
           luma = 1;
         }
-      
+
       else if (!strcmp (arg, "chroma"))
         {
           chroma = 1;
@@ -101,21 +101,21 @@ babl_component_new (void *first_arg,
         {
           alpha = 1;
         }
-      
+
       else
         {
           babl_fatal ("unhandled argument '%s' for format '%s'", arg, first_arg);
         }
     }
-    
-  va_end   (varg);
+
+  va_end (varg);
 
   babl = component_new (first_arg, id, luma, chroma, alpha);
 
-  { 
+  {
     Babl *ret = babl_db_insert (db, babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     return ret;
   }
 }
index 7dc1f37931ce7463afd330f3d12cb525218c8042..9b5b40ce3b980b7d93796d608ff50123c2a76976 100644 (file)
@@ -33,36 +33,36 @@ each_babl_conversion_destroy (Babl *babl,
 }
 
 static Babl *
-conversion_new (const char        *name,
-                int                id,
-                Babl              *source,
-                Babl              *destination,
-                BablFuncLinear     linear,
-                BablFuncPlane      plane,
-                BablFuncPlanar     planar)
+conversion_new (const char    *name,
+                int            id,
+                Babl          *source,
+                Babl          *destination,
+                BablFuncLinear linear,
+                BablFuncPlane  plane,
+                BablFuncPlanar planar)
 {
   Babl *babl = NULL;
 
   babl_assert (source->class_type ==
                destination->class_type);
 
-  babl = babl_malloc (sizeof (BablConversion) + strlen (name) + 1);
-  babl->instance.name = (char *)babl + sizeof (BablConversion);
-  strcpy(babl->instance.name, name);
+  babl                = babl_malloc (sizeof (BablConversion) + strlen (name) + 1);
+  babl->instance.name = (char *) babl + sizeof (BablConversion);
+  strcpy (babl->instance.name, name);
 
   if (linear)
     {
-      babl->class_type      = BABL_CONVERSION_LINEAR;
+      babl->class_type                 = BABL_CONVERSION_LINEAR;
       babl->conversion.function.linear = linear;
     }
   else if (plane)
     {
-      babl->class_type      = BABL_CONVERSION_PLANE;
+      babl->class_type                = BABL_CONVERSION_PLANE;
       babl->conversion.function.plane = plane;
     }
   else if (planar)
     {
-      babl->class_type = BABL_CONVERSION_PLANAR;
+      babl->class_type                 = BABL_CONVERSION_PLANAR;
       babl->conversion.function.planar = planar;
     }
   switch (source->class_type)
@@ -84,6 +84,7 @@ conversion_new (const char        *name,
                         babl_class_name (source->class_type));
           }
         break;
+
       case BABL_MODEL:
         if (plane)
           {
@@ -91,10 +92,12 @@ conversion_new (const char        *name,
                         babl_class_name (source->class_type));
           }
         break;
+
       case BABL_FORMAT:
         break;
+
       default:
-          babl_fatal ("%s unexpected", babl_class_name (babl->class_type));
+        babl_fatal ("%s unexpected", babl_class_name (babl->class_type));
         break;
     }
 
@@ -108,64 +111,63 @@ conversion_new (const char        *name,
   babl->conversion.processings = 0;
 
   if (babl->class_type == BABL_CONVERSION_LINEAR &&
-      BABL(babl->conversion.source)->class_type == BABL_MODEL)
+      BABL (babl->conversion.source)->class_type == BABL_MODEL)
     {
-       Babl *src_format=NULL;
-       Babl *dst_format=NULL;
-       if (BABL(babl->conversion.source) == babl_model_id (BABL_RGBA))
-         {
-           src_format = babl_format_id (BABL_RGBA_DOUBLE);
-           dst_format = babl_format_with_model_as_type (
-                                BABL(babl->conversion.destination),
-                                babl_type_id (BABL_DOUBLE));
-         }
-       else if (BABL(babl->conversion.destination) == babl_model_id (BABL_RGBA))
-         {
-           src_format = babl_format_with_model_as_type (
-                                BABL(babl->conversion.source),
-                                babl_type_id (BABL_DOUBLE));
-           dst_format = babl_format_id (BABL_RGBA_DOUBLE);
-         }
-       else
-         {
-           babl_fatal ("neither source nor destination model is RGBA (requirement might be temporary)");
-         }
-       babl_conversion_new (
-          src_format,
-          dst_format,
-          "linear", linear,
-          NULL);
-       babl->conversion.error = 0.0;
+      Babl *src_format = NULL;
+      Babl *dst_format = NULL;
+      if (BABL (babl->conversion.source) == babl_model_id (BABL_RGBA))
+        {
+          src_format = babl_format_id (BABL_RGBA_DOUBLE);
+          dst_format = babl_format_with_model_as_type (
+            BABL (babl->conversion.destination),
+            babl_type_id (BABL_DOUBLE));
+        }
+      else if (BABL (babl->conversion.destination) == babl_model_id (BABL_RGBA))
+        {
+          src_format = babl_format_with_model_as_type (
+            BABL (babl->conversion.source),
+            babl_type_id (BABL_DOUBLE));
+          dst_format = babl_format_id (BABL_RGBA_DOUBLE);
+        }
+      else
+        {
+          babl_fatal ("neither source nor destination model is RGBA (requirement might be temporary)");
+        }
+      babl_conversion_new (
+        src_format,
+        dst_format,
+        "linear", linear,
+        NULL);
+      babl->conversion.error = 0.0;
     }
 
   return babl;
 }
 
-static char buf[512]="";
+static char buf[512] = "";
 static char *
 create_name (Babl *source, Babl *destination, int type)
 {
-
   if (babl_extender ())
     {
-      snprintf (buf, 512-1, "%s : %s%s to %s",
-          BABL(babl_extender())->instance.name,
-          type == BABL_CONVERSION_LINEAR?"":
-          type == BABL_CONVERSION_PLANE?"plane ":
-          type == BABL_CONVERSION_PLANAR?"planar ":"Eeeek! ",
-          source->instance.name,
-          destination->instance.name);
-      buf[511]='\0';
+      snprintf (buf, 512 - 1, "%s : %s%s to %s",
+                BABL (babl_extender ())->instance.name,
+                type == BABL_CONVERSION_LINEAR ? "" :
+                type == BABL_CONVERSION_PLANE ? "plane " :
+                type == BABL_CONVERSION_PLANAR ? "planar " : "Eeeek! ",
+                source->instance.name,
+                destination->instance.name);
+      buf[511] = '\0';
     }
   else
     {
-      snprintf (buf, 512-1, "%s %s to %s",
-          type == BABL_CONVERSION_LINEAR?"":
-          type == BABL_CONVERSION_PLANE?"plane ":
-          type == BABL_CONVERSION_PLANAR?"planar ":"Eeeek! ",
-          source->instance.name,
-          destination->instance.name);
-      buf[511]='\0';
+      snprintf (buf, 512 - 1, "%s %s to %s",
+                type == BABL_CONVERSION_LINEAR ? "" :
+                type == BABL_CONVERSION_PLANE ? "plane " :
+                type == BABL_CONVERSION_PLANAR ? "planar " : "Eeeek! ",
+                source->instance.name,
+                destination->instance.name);
+      buf[511] = '\0';
     }
   return buf;
 }
@@ -174,32 +176,31 @@ Babl *
 babl_conversion_new (void *first_arg,
                      ...)
 {
-  va_list            varg;
-  Babl              *babl;
+  va_list        varg;
+  Babl          *babl;
 
-  int                id          = 0;
-  BablFuncLinear     linear      = NULL;
-  BablFuncPlane      plane       = NULL;
-  BablFuncPlanar     planar      = NULL;
-  int                type        = 0;
-  int                got_func    = 0;
-  const char        *arg         = first_arg;
+  int            id       = 0;
+  BablFuncLinear linear   = NULL;
+  BablFuncPlane  plane    = NULL;
+  BablFuncPlanar planar   = NULL;
+  int            type     = 0;
+  int            got_func = 0;
+  const char    *arg      = first_arg;
 
-  Babl *source;
-  Babl *destination;
+  Babl          *source;
+  Babl          *destination;
 
   va_start (varg, first_arg);
-  source = (Babl*) arg;
-  destination = va_arg (varg, Babl*);
-  arg = va_arg (varg, char *);
+  source      = (Babl *) arg;
+  destination = va_arg (varg, Babl *);
+  arg         = va_arg (varg, char *);
 
-  assert (BABL_IS_BABL(source));
-  assert (BABL_IS_BABL(destination));
+  assert (BABL_IS_BABL (source));
+  assert (BABL_IS_BABL (destination));
 
 
   while (arg)
     {
-
       if (!strcmp (arg, "id"))
         {
           id = va_arg (varg, int);
@@ -240,7 +241,7 @@ babl_conversion_new (void *first_arg,
       arg = va_arg (varg, char *);
     }
 
-  va_end   (varg);
+  va_end (varg);
 
   assert (source);
   assert (destination);
@@ -258,14 +259,14 @@ babl_conversion_new (void *first_arg,
       type = BABL_CONVERSION_PLANAR;
     }
   babl = conversion_new (create_name (source, destination, type),
-       id, source, destination, linear, plane, planar);
+                         id, source, destination, linear, plane, planar);
 
   {
     Babl *ret = babl_db_insert (db, babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     else
-        babl_add_ptr_to_list ((void ***)((Babl*)&(source->type.from)), babl);
+      babl_add_ptr_to_list ((void ***) ((Babl *) &(source->type.from)), babl);
 
     return ret;
   }
@@ -288,7 +289,7 @@ babl_conversion_plane_process (BablConversion *conversion,
                                int             dst_pitch,
                                long            n)
 {
-  return conversion->function.plane (source,    destination,
+  return conversion->function.plane (source, destination,
                                      src_pitch, dst_pitch,
                                      n);
 }
@@ -300,15 +301,15 @@ babl_conversion_planar_process (BablConversion *conversion,
                                 long            n)
 {
 #ifdef USE_ALLOCA
-  char **src_data = alloca (sizeof (void*) * source->components);
-  char **dst_data = alloca (sizeof (void*) * destination->components);
+  char **src_data = alloca (sizeof (void *) * source->components);
+  char **dst_data = alloca (sizeof (void *) * destination->components);
 #else
-  char *src_data[BABL_MAX_COMPONENTS];
-  char *dst_data[BABL_MAX_COMPONENTS];
+  char  *src_data[BABL_MAX_COMPONENTS];
+  char  *dst_data[BABL_MAX_COMPONENTS];
 #endif
 
-  memcpy (src_data, source->data, sizeof (void*) * source->components);
-  memcpy (dst_data, destination->data, sizeof (void*) * destination->components);
+  memcpy (src_data, source->data, sizeof (void *) * source->components);
+  memcpy (dst_data, destination->data, sizeof (void *) * destination->components);
 
   return conversion->function.planar (source->components,
                                       src_data,
@@ -325,85 +326,87 @@ babl_conversion_process (Babl *babl,
                          char *destination,
                          long  n)
 {
-  BablConversion *conversion = (BablConversion*) babl;
+  BablConversion *conversion = (BablConversion *) babl;
 
   babl_assert (BABL_IS_BABL (conversion));
 
-  switch (BABL(conversion)->class_type)
-  {
-    case BABL_CONVERSION_PLANE:
+  switch (BABL (conversion)->class_type)
+    {
+      case BABL_CONVERSION_PLANE:
       {
-        void *src_data = NULL;
-        void *dst_data = NULL;
+        void *src_data  = NULL;
+        void *dst_data  = NULL;
         int   src_pitch = 0;
         int   dst_pitch = 0;
 
-        if (BABL_IS_BABL(source))
+        if (BABL_IS_BABL (source))
           {
             BablImage *img;
 
-            img       = (BablImage*)source;
+            img       = (BablImage *) source;
             src_data  = img->data[0];
             src_pitch = img->pitch[0];
           }
-        if (BABL_IS_BABL(destination))
+        if (BABL_IS_BABL (destination))
           {
-            BablImage *img = (BablImage*)destination;
+            BablImage *img = (BablImage *) destination;
 
             dst_data  = img->data[0];
             dst_pitch = img->pitch[0];
           }
 
         if (!src_data)
-          src_data=source;
+          src_data = source;
         if (!src_pitch)
-          src_pitch=BABL(conversion->source)->type.bits/8;
+          src_pitch = BABL (conversion->source)->type.bits / 8;
         if (!dst_data)
-          dst_data=destination;
+          dst_data = destination;
         if (!dst_pitch)
-          dst_pitch=BABL(conversion->destination)->type.bits/8;
+          dst_pitch = BABL (conversion->destination)->type.bits / 8;
 
         babl_conversion_plane_process (conversion,
-                                       src_data,  dst_data,
+                                       src_data, dst_data,
                                        src_pitch, dst_pitch,
                                        n);
       }
-      break;
-    case BABL_CONVERSION_PLANAR:
-      babl_assert (BABL_IS_BABL (source));
-      babl_assert (BABL_IS_BABL (destination));
-
-      babl_conversion_planar_process (                  conversion,
-                                      (BablImage*)      source,
-                                      (BablImage*)      destination,
-                                                        n);
-      break;
-    case BABL_CONVERSION_LINEAR:
-      /* the assertions relied on a babl_malloc structure
-       *
-       * babl_assert (!BABL_IS_BABL (source));
-      babl_assert (!BABL_IS_BABL (destination));*/
-
-      babl_conversion_linear_process (conversion,
-                                      source,
-                                      destination,
-                                      n);
-      break;
-
-    default:
-      babl_log ("args=(%s, %p, %p, %li) unhandled conversion type: %s",
-           conversion->instance.name, source, destination, n,
-          babl_class_name (conversion->instance.class_type));
-      return 0;
-      break;
-  }
+        break;
+
+      case BABL_CONVERSION_PLANAR:
+        babl_assert (BABL_IS_BABL (source));
+        babl_assert (BABL_IS_BABL (destination));
+
+        babl_conversion_planar_process (conversion,
+                                        (BablImage *) source,
+                                        (BablImage *) destination,
+                                        n);
+        break;
 
-  conversion->processings ++;
+      case BABL_CONVERSION_LINEAR:
+        /* the assertions relied on a babl_malloc structure
+         *
+         * babl_assert (!BABL_IS_BABL (source));
+           babl_assert (!BABL_IS_BABL (destination));*/
+
+        babl_conversion_linear_process (conversion,
+                                        source,
+                                        destination,
+                                        n);
+        break;
+
+      default:
+        babl_log ("args=(%s, %p, %p, %li) unhandled conversion type: %s",
+                  conversion->instance.name, source, destination, n,
+                  babl_class_name (conversion->instance.class_type));
+        return 0;
+        break;
+    }
+
+  conversion->processings++;
   conversion->pixels += n;
   return n;
 }
 
-#define test_pixels   512
+#define test_pixels    512
 
 static double *
 test_create (void)
@@ -416,7 +419,7 @@ test_create (void)
   test = babl_malloc (sizeof (double) * test_pixels * 4);
 
   for (i = 0; i < test_pixels * 4; i++)
-     test [i] = (double) random () / RAND_MAX;
+    test [i] = (double) random () / RAND_MAX;
   return test;
 }
 
@@ -425,7 +428,7 @@ babl_conversion_cost (BablConversion *conversion)
 {
   if (!conversion)
     return 100000000L;
-  if (conversion->error==-1.0)
+  if (conversion->error == -1.0)
     babl_conversion_error (conversion);
   return conversion->cost;
 }
@@ -436,35 +439,34 @@ babl_conversion_error (BablConversion *conversion)
   Babl *fmt_source;
   Babl *fmt_destination;
 
-  Babl *fmt_rgba_double = fmt_rgba_double = babl_format_new (
-       babl_model     ("RGBA"),
-       babl_type      ("double"),
-       babl_component ("R"),
-       babl_component ("G"),
-       babl_component ("B"),
-       babl_component ("A"),
-       NULL);
-
-  double   error = 0.0;
-  long     ticks_start = 0;
-  long     ticks_end   = 0;
-
-  double  *test;
-  void    *source;
-  void    *destination;
-  double  *destination_rgba_double;
-  void    *ref_destination;
-  double  *ref_destination_rgba_double;
-
-  Babl *fish_rgba_to_source;
-  Babl *fish_reference;
-  Babl *fish_destination_to_rgba;
+  Babl *fmt_rgba_double = babl_format_new (babl_model ("RGBA"),
+                                           babl_type ("double"),
+                                           babl_component ("R"),
+                                           babl_component ("G"),
+                                           babl_component ("B"),
+                                           babl_component ("A"),
+                                           NULL);
+
+  double  error       = 0.0;
+  long    ticks_start = 0;
+  long    ticks_end   = 0;
+
+  double *test;
+  void   *source;
+  void   *destination;
+  double *destination_rgba_double;
+  void   *ref_destination;
+  double *ref_destination_rgba_double;
+
+  Babl   *fish_rgba_to_source;
+  Babl   *fish_reference;
+  Babl   *fish_destination_to_rgba;
 
   if (!conversion)
     return 0.0;
 
-  fmt_source      = BABL(conversion->source);
-  fmt_destination = BABL(conversion->destination);
+  fmt_source      = BABL (conversion->source);
+  fmt_destination = BABL (conversion->destination);
 
   fish_rgba_to_source      = babl_fish_reference (fmt_rgba_double, fmt_source);
   fish_reference           = babl_fish_reference (fmt_source, fmt_destination);
@@ -476,12 +478,12 @@ babl_conversion_error (BablConversion *conversion)
       return 0.0;
     }
 
-  if (!(fmt_source->instance.id    != BABL_RGBA   &&
-      fmt_destination->instance.id != BABL_RGBA   &&
-      fmt_source->instance.id      != BABL_DOUBLE &&
-      fmt_destination->instance.id != BABL_DOUBLE &&
-      fmt_source->class_type       == BABL_FORMAT &&
-      fmt_destination->class_type  == BABL_FORMAT))
+  if (!(fmt_source->instance.id != BABL_RGBA &&
+        fmt_destination->instance.id != BABL_RGBA &&
+        fmt_source->instance.id != BABL_DOUBLE &&
+        fmt_destination->instance.id != BABL_DOUBLE &&
+        fmt_source->class_type == BABL_FORMAT &&
+        fmt_destination->class_type == BABL_FORMAT))
     {
       conversion->error = 0.000042;
     }
@@ -490,41 +492,41 @@ babl_conversion_error (BablConversion *conversion)
       return conversion->error;
     }
 
-  test=test_create ();
+  test = test_create ();
 
 
-  source          = babl_calloc (test_pixels, fmt_source->format.bytes_per_pixel);
-  destination     = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
-  ref_destination = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
+  source                      = babl_calloc (test_pixels, fmt_source->format.bytes_per_pixel);
+  destination                 = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
+  ref_destination             = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
   destination_rgba_double     = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
   ref_destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
 
   babl_process (fish_rgba_to_source,
-      test, source, test_pixels);
+                test, source, test_pixels);
 
   ticks_start = babl_ticks ();
   babl_process (babl_fish_simple (conversion),
-      source, destination, test_pixels);
+                source, destination, test_pixels);
   ticks_end = babl_ticks ();
 
   babl_process (fish_reference,
-      source, ref_destination, test_pixels);
+                source, ref_destination, test_pixels);
 
   babl_process (fish_destination_to_rgba,
-      ref_destination, ref_destination_rgba_double, test_pixels);
+                ref_destination, ref_destination_rgba_double, test_pixels);
   babl_process (fish_destination_to_rgba,
-      destination, destination_rgba_double, test_pixels);
+                destination, destination_rgba_double, test_pixels);
 
   error = babl_rel_avg_error (destination_rgba_double,
                               ref_destination_rgba_double,
-                              test_pixels*4);
+                              test_pixels * 4);
 
   fish_rgba_to_source->fish.processings--;
   fish_reference->fish.processings--;
-  fish_destination_to_rgba->fish.processings-=2;
+  fish_destination_to_rgba->fish.processings -= 2;
 
-  fish_rgba_to_source->fish.pixels -= test_pixels;
-  fish_reference->fish.pixels -= test_pixels;
+  fish_rgba_to_source->fish.pixels      -= test_pixels;
+  fish_reference->fish.pixels           -= test_pixels;
   fish_destination_to_rgba->fish.pixels -= 2 * test_pixels;
 
 
@@ -536,7 +538,7 @@ babl_conversion_error (BablConversion *conversion)
   babl_free (test);
 
   conversion->error = error;
-  conversion->cost  = (ticks_end-ticks_start)*10+1;
+  conversion->cost  = (ticks_end - ticks_start) * 10 + 1;
 
   return error;
 }
index 05e457633d6f752f6d4a26dca9c46a0e28b03327..05d30aef729d28941948864a5a74a88eb9e2b15a 100644 (file)
@@ -1,5 +1,5 @@
 /* babl - dynamically extendable universal pixel conversion library.
-   
+
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -31,31 +31,31 @@ convert_double_double (char *src,
   if (src_pitch == 64 &&
       dst_pitch == 64)
     {
-      memcpy (dst, src, n/8);
+      memcpy (dst, src, n / 8);
       return n;
     }
 
   while (n--)
     {
       (*(double *) dst) = (*(double *) src);
-      dst += dst_pitch;
-      src += src_pitch;
+      dst              += dst_pitch;
+      src              += src_pitch;
     }
   return n;
 }
 
 /*
-static long
-copy_strip_1 (int    src_bands,
+   static long
+   copy_strip_1 (int    src_bands,
               char **src,
               int   *src_pitch,
               int    dst_bands,
               char **dst,
               int   *dst_pitch,
               long   n)
-{
-  BABL_PLANAR_SANITY
-  while (n--)
+   {
+   BABL_PLANAR_SANITY
+   while (n--)
     {
       int i;
 
@@ -66,16 +66,16 @@ copy_strip_1 (int    src_bands,
             foo = *(double *) src[i];
           else
             foo = 1.0;
         *(double*)dst[i] = foo;
+ *(double*)dst[i] = foo;
         }
 
       BABL_PLANAR_STEP
     }
-  return n;
-}
+   return n;
+   }
 
 
-*/
+ */
 static long
 rgba_to_rgba (char *src,
               char *dst,
@@ -89,8 +89,8 @@ babl_core_init (void)
 {
   babl_type_new (
     "double",
-    "id",          BABL_DOUBLE,
-    "bits",        64,
+    "id", BABL_DOUBLE,
+    "bits", 64,
     NULL);
 
   babl_component_new (
@@ -101,29 +101,29 @@ babl_core_init (void)
     NULL);
 
   babl_component_new (
-   "G",
-    "id",   BABL_GREEN,
-   "luma", 
-   "chroma",
-   NULL);
-  
+    "G",
+    "id", BABL_GREEN,
+    "luma",
+    "chroma",
+    NULL);
+
   babl_component_new (
-   "B",
-    "id",   BABL_BLUE,
-   "luma",
-   "chroma",
-   NULL);
+    "B",
+    "id", BABL_BLUE,
+    "luma",
+    "chroma",
+    NULL);
 
   babl_component_new (
-   "A",
-   "id",    BABL_ALPHA,
-   "alpha",
-   NULL);
+    "A",
+    "id", BABL_ALPHA,
+    "alpha",
+    NULL);
 
   babl_component_new (
-   "PAD",
-   "id",    BABL_PADDING,
-   NULL);
+    "PAD",
+    "id", BABL_PADDING,
+    NULL);
 
   babl_model_new (
     "id", BABL_RGBA,
@@ -144,25 +144,25 @@ babl_core_init (void)
     NULL);
 
   /*
-  babl_conversion_new (
-    babl_model_id (BABL_RGBA),
-    babl_model_id (BABL_RGBA),
-    "planar",      copy_strip_1,
-    NULL
-  );
-  */
+     babl_conversion_new (
+     babl_model_id (BABL_RGBA),
+     babl_model_id (BABL_RGBA),
+     "planar",      copy_strip_1,
+     NULL
+     );
+   */
 
   babl_conversion_new (
     babl_type_id (BABL_DOUBLE),
     babl_type_id (BABL_DOUBLE),
-    "plane",      convert_double_double,
+    "plane", convert_double_double,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_RGBA),
-    "linear",      rgba_to_rgba,
+    "linear", rgba_to_rgba,
     NULL
   );
 }
index 3e70900171f24fe4f32a5c71d4d835358d50b025..22acb2e3dda177f68513c26fc8913a1dd1032b71 100644 (file)
@@ -22,9 +22,9 @@
 #include <string.h>
 #include "babl-internal.h"
 
-#define HASH_TABLE_SIZE    128
-#define DB_INITIAL_SIZE    16 
-#define DB_INCREMENT_SIZE  16
+#define HASH_TABLE_SIZE      128
+#define DB_INITIAL_SIZE      16
+#define DB_INCREMENT_SIZE    16
 
 static inline int hash (const char *str)
 {
@@ -32,11 +32,12 @@ static inline int hash (const char *str)
   int i   = 1;
 
   while (*str)
-    ret = (ret + ( i++ * (*str ++ & 31 ))) % (HASH_TABLE_SIZE-1);
+    ret = (ret + (i++ * (*str++ & 31))) % (HASH_TABLE_SIZE - 1);
   return ret;
 }
 
-typedef struct _BablDb {
+typedef struct _BablDb
+{
   Babl  *hash [HASH_TABLE_SIZE];
   int    size;
   int    count;
@@ -62,15 +63,16 @@ babl_db_find (BablDb     *db,
 
 
 BablDb *
-babl_db_init(void)
+babl_db_init (void)
 {
   BablDb *db = babl_calloc (sizeof (BablDb), 1);
+
   db->size  = DB_INITIAL_SIZE;
   db->count = 0;
   db->items = NULL;
   if (db->size)
     {
-      db->items = babl_calloc (sizeof (BablInstance*), db->size);
+      db->items = babl_calloc (sizeof (BablInstance *), db->size);
     }
   return db;
 }
@@ -101,19 +103,19 @@ babl_db_insert (BablDb *db,
   collision = babl_db_exist (db, item->instance.id, item->instance.name);
 
   if (collision)
-     return collision;
+    return collision;
 
   if (db->count + 1 > db->size)     /* must reallocate storage */
     {
       Babl **new_items;
 
-      new_items = babl_realloc (db->items, (db->size + DB_INCREMENT_SIZE) * sizeof (BablInstance*));
+      new_items = babl_realloc (db->items, (db->size + DB_INCREMENT_SIZE) * sizeof (BablInstance *));
       babl_assert (new_items);
 
       db->items = new_items;
 
       /* null out the currently unused portions of memory */
-      memset (db->items + db->size, 0, DB_INCREMENT_SIZE * sizeof (Babl*));
+      memset (db->items + db->size, 0, DB_INCREMENT_SIZE * sizeof (Babl *));
       db->size += DB_INCREMENT_SIZE;
     }
 
@@ -122,26 +124,26 @@ babl_db_insert (BablDb *db,
     if (db->hash[key] == NULL)
       db->hash[key] = item;
   }
-  db->items[db->count++]=item;
+  db->items[db->count++] = item;
 
   /* this point all registered items pass through, a nice
-   * place to brand them with where the item came from. */
+  * place to brand them with where the item came from. */
   item->instance.creator = babl_extender ();
   return item;
 }
 
 void
-babl_db_each (BablDb           *db,
-              BablEachFunction  each_fun,
-              void             *user_data)
+babl_db_each (BablDb          *db,
+              BablEachFunction each_fun,
+              void            *user_data)
 {
   int i;
 
-  for (i=0; i< db->count; i++)
+  for (i = 0; i < db->count; i++)
     {
       if (db->items[i])
         {
-          if (each_fun ((Babl*) db->items[i], user_data))
+          if (each_fun ((Babl *) db->items[i], user_data))
             break;
         }
     }
@@ -149,12 +151,12 @@ babl_db_each (BablDb           *db,
 
 typedef struct BablDbExistData
 {
-  int          id;
-  const char  *name;
-  Babl        *ret;
+  int         id;
+  const char *name;
+  Babl       *ret;
 } BablDbExistData;
 
-static int 
+static int
 babl_db_each_exist (Babl *babl,
                     void *void_data)
 {
@@ -162,8 +164,8 @@ babl_db_each_exist (Babl *babl,
 
   if (data->id && data->id == babl->instance.id)
     {
-          data->ret = babl;
-          return 1; /* stop iterating */
+      data->ret = babl;
+      return 1;     /* stop iterating */
     }
   else if (data->name && !strcmp (babl->instance.name, data->name))
     {
@@ -173,7 +175,7 @@ babl_db_each_exist (Babl *babl,
   return 0;  /* continue iterating */
 }
 
-Babl * 
+Babl *
 babl_db_exist (BablDb     *db,
                int         id,
                const char *name)
@@ -181,18 +183,18 @@ babl_db_exist (BablDb     *db,
   Babl *ret = NULL;
 
   if (name)
-      ret = db->hash[hash (name)];
+    ret = db->hash[hash (name)];
   if (ret &&
       name[0] == ret->instance.name[0] &&
       !strcmp (name, ret->instance.name))
-      return ret;
+    return ret;
 
   {
     BablDbExistData data;
 
-    data.id = id;
+    data.id   = id;
     data.name = name;
-    data.ret = NULL;
+    data.ret  = NULL;
 
     babl_db_each (db, babl_db_each_exist, &data);
 
index 3047bee7d8dbfd453a3ed9486bf333394fbb74b0..c686e7de273bdc3f473fe11384ae5a07f9e7b430 100644 (file)
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #else
-#define BABL_PATH           PREFIX "/babl-0.0"
-#define BABL_PATH_SEPERATOR "/"
-#define BABL_LIST_SEPERATOR ':'
+#define BABL_PATH              PREFIX "/babl-0.0"
+#define BABL_PATH_SEPERATOR    "/"
+#define BABL_LIST_SEPERATOR    ':'
 #endif
 
-#define BABL_INIT_HOOK     init_hook();
-#define BABL_DESTROY_HOOK  destroy_hook();
+#define BABL_INIT_HOOK         init_hook ();
+#define BABL_DESTROY_HOOK      destroy_hook ();
 
 #ifdef BABL_DYNAMIC_EXTENSIONS
-        /* must be defined before inclusion of babl-internal.h */ 
+/* must be defined before inclusion of babl-internal.h */
 #undef  BABL_INIT_HOOK
-#define BABL_INIT_HOOK  init_hook();dynamic_init_hook();
+#define BABL_INIT_HOOK    init_hook (); dynamic_init_hook ();
 #endif
 
 #include "babl-internal.h"
@@ -63,17 +63,17 @@ babl_set_extender (Babl *new_extender)
 static Babl *
 extension_new (const char *path,
                void       *dl_handle,
-               void      (*destroy) (void))
+               void        (*destroy)(void))
 {
   Babl *babl;
 
-  babl                       = babl_malloc (sizeof (BablExtension) + strlen (path) + 1);
-  babl->instance.name        = (char *) babl + sizeof (BablExtension);
+  babl                = babl_malloc (sizeof (BablExtension) + strlen (path) + 1);
+  babl->instance.name = (char *) babl + sizeof (BablExtension);
   strcpy (babl->instance.name, path);
-  babl->instance.id          = 0;
-  babl->class_type           = BABL_EXTENSION;
-  babl->extension.dl_handle  = dl_handle;
-  babl->extension.destroy    = destroy;
+  babl->instance.id         = 0;
+  babl->class_type          = BABL_EXTENSION;
+  babl->extension.dl_handle = dl_handle;
+  babl->extension.destroy   = destroy;
 
   return babl;
 }
@@ -93,22 +93,23 @@ Babl *
 babl_extension_base (void)
 {
   Babl *babl;
-  void *dl_handle        = NULL;
-  void (*destroy) (void) = NULL;
+  void *dl_handle = NULL;
 
-  if (!db) 
+  void  (*destroy)(void) = NULL;
+
+  if (!db)
     db = babl_db_init ();
   babl = extension_new ("BablBase",
                         dl_handle,
                         destroy);
   babl_set_extender (babl);
 
-  { 
+  {
     Babl *ret = babl_db_insert (db, babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     else
-        babl_base_init ();
+      babl_base_init ();
     babl = ret;
   }
   babl_set_extender (NULL);
@@ -126,7 +127,7 @@ static void
 destroy_hook (void)
 {
   babl_free (babl_quiet);
-  babl_quiet=NULL;
+  babl_quiet = NULL;
 }
 
 #ifdef BABL_DYNAMIC_EXTENSIONS
@@ -138,23 +139,23 @@ destroy_hook (void)
 
 #ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
-#define HLIB void *
+#define HLIB    void *
 #endif
 
 #ifndef RTLD_NOW
-#define RTLD_NOW 0
+#define RTLD_NOW    0
 #endif
 
-#ifdef WIN32 
-#define WIN32_LEAN_AND_MEAN 
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#define HLIB   HINSTANCE
+#define HLIB    HINSTANCE
 
-#define dlopen(a, b) LoadLibrary(a) 
-#define dlsym(l, s)  GetProcAddress(l, s) 
-#define dlclose(l)   FreeLibrary(l) 
-#define dlerror()    GetLastError()
-#endif 
+#define dlopen(a, b)    LoadLibrary (a)
+#define dlsym(l, s)     GetProcAddress (l, s)
+#define dlclose(l)      FreeLibrary (l)
+#define dlerror()       GetLastError ()
+#endif
 
 static Babl *
 load_failed (Babl *babl)
@@ -170,32 +171,33 @@ load_failed (Babl *babl)
 static Babl *
 babl_extension_load (const char *path)
 {
-  Babl *babl             = NULL;
+  Babl *babl = NULL;
   /* do the actual loading thing */
-  HLIB dl_handle         = NULL;
-  int  (*init)    (void) = NULL;
-  void (*destroy) (void) = NULL;
+  HLIB  dl_handle = NULL;
+
+  int   (*init)(void)    = NULL;
+  void  (*destroy)(void) = NULL;
+
   dl_handle = dlopen (path, RTLD_NOW);
   if (!dl_handle)
     {
       babl_log ("dlopen() failed:\n\t%s", dlerror ());
       return load_failed (babl);
     }
-  init    = dlsym (dl_handle, "init");
+  init = dlsym (dl_handle, "init");
   if (!init)
     {
       babl_log ("\n\tint babl_extension_init() function not found in extenstion '%s'", path);
       return load_failed (babl);
     }
+
   destroy = dlsym (dl_handle, "destroy");
-  babl = extension_new (path,
-                        dl_handle,
-                        destroy);
+  babl    = extension_new (path,
+                           dl_handle,
+                           destroy);
 
   babl_set_extender (babl);
-  if(init())
+  if (init ())
     {
       babl_log ("babl_extension_init() in extension '%s' failed (return!=0)", path);
       return load_failed (babl);
@@ -215,45 +217,44 @@ babl_extension_load (const char *path)
 static void
 babl_extension_load_dir (const char *base_path)
 {
-  DIR            *dir;
+  DIR *dir;
 
   if ((dir = opendir (base_path)))
-   {
-     struct  dirent *dentry;
-
-     while ((dentry = readdir (dir)) != NULL)
-       {
-         if (dentry->d_name[0] != '.')
-           {
-             char   *path = NULL;
-             struct  stat st;
-             char   *extension;
-
-             path = babl_strcat (path, base_path);
-             path = babl_strcat (path, BABL_PATH_SEPERATOR);
-             path = babl_strcat (path, dentry->d_name);
-
-             stat (path, &st);
-
-             if ((extension = strrchr (dentry->d_name, '.')) !=NULL &&
-                 !strcmp (extension, SHREXT))
-               {
-                  babl_extension_load (path);
-               }
+    {
+      struct  dirent *dentry;
+
+      while ((dentry = readdir (dir)) != NULL)
+        {
+          if (dentry->d_name[0] != '.')
+            {
+              char        *path = NULL;
+              struct  stat st;
+              char        *extension;
+
+              path = babl_strcat (path, base_path);
+              path = babl_strcat (path, BABL_PATH_SEPERATOR);
+              path = babl_strcat (path, dentry->d_name);
+
+              stat (path, &st);
 
-             babl_free (path);
-           }
+              if ((extension = strrchr (dentry->d_name, '.')) != NULL &&
+                  !strcmp (extension, SHREXT))
+                {
+                  babl_extension_load (path);
+                }
 
-       }
-     closedir (dir);
-   }
+              babl_free (path);
+            }
+        }
+      closedir (dir);
+    }
 }
 
 static const char *
 babl_dir_list (void)
 {
   const char *ret;
-  
+
   ret = getenv ("BABL_PATH");
   if (!ret)
     ret = BABL_PATH;
@@ -268,21 +269,22 @@ expand_path (char *path)
 
   dst = NULL;
 
-  src=path;
+  src = path;
 
-  while(*src)
+  while (*src)
     {
       switch (*src)
         {
           case '~':
             dst = babl_strcat (dst, getenv ("HOME"));
             break;
+
           default:
-            {
-              char tmp[2]="?";
-              tmp[0]=*src;
-              dst = babl_strcat (dst, tmp);
-            }
+          {
+            char tmp[2] = "?";
+            tmp[0] = *src;
+            dst    = babl_strcat (dst, tmp);
+          }
         }
       src++;
     }
@@ -295,35 +297,37 @@ expand_path (char *path)
 static void
 babl_extension_load_dir_list (const char *dir_list)
 {
-  int eos = 0;
+  int         eos = 0;
   const char *src;
   char       *path, *dst;
 
 
   path = babl_strdup (dir_list);
-  src = dir_list;
-  dst = path;
+  src  = dir_list;
+  dst  = path;
 
   while (!eos)
     {
       switch (*src)
         {
-        case '\0':
-          eos=1;
-        case BABL_LIST_SEPERATOR:
-            {
-              char *expanded_path = expand_path (path);
-              babl_extension_load_dir (expanded_path);
-              babl_free (expanded_path);
-            }
-          dst=path;
-          src++;
-          *dst = '\0';
-          break;
-        default:
-          *(dst++) = *(src++);
-          *dst = '\0';
-          break;
+          case '\0':
+            eos = 1;
+
+          case BABL_LIST_SEPERATOR:
+          {
+            char *expanded_path = expand_path (path);
+            babl_extension_load_dir (expanded_path);
+            babl_free (expanded_path);
+          }
+            dst = path;
+            src++;
+            *dst = '\0';
+            break;
+
+          default:
+            *(dst++) = *(src++);
+            *dst     = '\0';
+            break;
         }
     }
   babl_free (path);
@@ -337,12 +341,12 @@ dynamic_init_hook (void)
 
 #endif
 
-static int 
+static int
 each_babl_extension_destroy (Babl *babl,
                              void *data)
 {
   if (babl->extension.destroy)
-    babl->extension.destroy();
+    babl->extension.destroy ();
   if (babl->extension.dl_handle)
     dlclose (babl->extension.dl_handle);
 
index 3dc99b3ad4bbb3441c3699dbae871e7990adccd7..826998c337e6305bc074d43b8b5c0d460000d42d 100644 (file)
@@ -31,29 +31,29 @@ chain_error (Babl            *fmt_source,
 
 static double legal_error (void)
 {
-  static double error=0.0;
-  const char *env;
+  static double error = 0.0;
+  const char   *env;
 
   if (error != 0.0)
     return error;
 
-  env=getenv ("BABL_ERROR");
+  env = getenv ("BABL_ERROR");
   if (env)
     error = atof (env);
-  else 
+  else
     error = 0.000001;
   return error;
 }
 
 static int max_path_length (void)
 {
-  static int  max_length=0;
+  static int  max_length = 0;
   const char *env;
 
   if (max_length != 0)
     return max_length;
 
-  env=getenv ("BABL_PATH_LENGTH");
+  env = getenv ("BABL_PATH_LENGTH");
   if (env)
     max_length = atoi (env);
   else
@@ -65,21 +65,22 @@ static int max_path_length (void)
   return max_length;
 }
 
-typedef struct BablChainContext {
-  Babl  *from;
-  Babl  *to;
+typedef struct BablChainContext
+{
+  Babl *from;
+  Babl *to;
 
   double *best_cost;
   double *best_loss;
   double *best_error;
 
   BablConversion **chain;
-  int   *conversions;
+  int             *conversions;
 
   BablConversion **temp_chain;
-  int    temp_conversions;
+  int              temp_conversions;
 
-  int    max_conversions;
+  int max_conversions;
 } BablChainContext;
 
 static int
@@ -87,30 +88,30 @@ chain_gen_each (Babl *babl,
                 void *userdata);
 
 static int
-get_conversion_chain (Babl             *from,
-                      Babl             *to,
-                      double           *best_cost,
-                      double           *best_loss,
-                      double           *best_error,
-                      BablConversion  **chain,
-                      int              *conversions,
-                      BablConversion  **temp_chain,
-                      int               temp_conversions,
-                      int               max_conversions)
+get_conversion_chain (Babl            *from,
+                      Babl            *to,
+                      double          *best_cost,
+                      double          *best_loss,
+                      double          *best_error,
+                      BablConversion **chain,
+                      int             *conversions,
+                      BablConversion **temp_chain,
+                      int              temp_conversions,
+                      int              max_conversions)
 {
   BablChainContext context;
 
-  if (temp_conversions>=max_conversions)
+  if (temp_conversions >= max_conversions)
     return 0;
 
   if (temp_conversions == 0)
     {
       /* chain initialization */
-      *conversions = 0;
-      *best_cost   = 200000.0;
-      *best_loss   = 200000.0;
-      *best_error  = 200000.0;
-      chain[0] = NULL;
+      *conversions  = 0;
+      *best_cost    = 200000.0;
+      *best_loss    = 200000.0;
+      *best_error   = 200000.0;
+      chain[0]      = NULL;
       temp_chain[0] = NULL;
 
       /* Bail out if requesting something stupid (to and from same format, an
@@ -118,48 +119,48 @@ get_conversion_chain (Babl             *from,
        */
 
       if (from == to)
-         return 0;
+        return 0;
     }
 
   /* copy parameters to stack */
-  context.from             = from;
-  context.to               = to;
+  context.from = from;
+  context.to   = to;
 
-  context.best_cost        = best_cost;
-  context.best_loss        = best_loss;
-  context.best_error       = best_error;
-  context.chain            = chain;
-  context.conversions      = conversions;
+  context.best_cost   = best_cost;
+  context.best_loss   = best_loss;
+  context.best_error  = best_error;
+  context.chain       = chain;
+  context.conversions = conversions;
 
   context.temp_chain       = temp_chain;
   context.temp_conversions = temp_conversions;
 
-  context.max_conversions  = max_conversions;
+  context.max_conversions = max_conversions;
 
   if (temp_conversions == 0)
     {
-      temp_chain[temp_conversions]=NULL;
+      temp_chain[temp_conversions] = NULL;
       babl_assert (from);
       babl_assert (from->class_type == BABL_FORMAT);
       if (!from->format.from)
         return 0;
 
-      babl_list_each ((void**) from->format.from,
-                       chain_gen_each,
-                       &context);
+      babl_list_each ((void **) from->format.from,
+                      chain_gen_each,
+                      &context);
     }
   else
     {
-      if (BABL(temp_chain[temp_conversions-1]) &&
-          BABL(temp_chain[temp_conversions-1]->destination)->
+      if (BABL (temp_chain[temp_conversions - 1]) &&
+          BABL (temp_chain[temp_conversions - 1]->destination)->
           format.from)
 
-         babl_list_each (
-           (void **)
-           BABL(temp_chain[temp_conversions-1]->destination)->
-           format.from,
-           chain_gen_each,
-           &context);
+        babl_list_each (
+          (void **)
+          BABL (temp_chain[temp_conversions - 1]->destination)->
+          format.from,
+          chain_gen_each,
+          &context);
     }
 
   return 0;
@@ -171,9 +172,10 @@ chain_contains_fmt (BablConversion **chain,
                     Babl            *fmt)
 {
   int i;
-  for (i=0;i<conversions;i++)
-    if (BABL(chain[i]->destination)==fmt ||
-        BABL(chain[i]->source)==fmt)
+
+  for (i = 0; i < conversions; i++)
+    if (BABL (chain[i]->destination) == fmt ||
+        BABL (chain[i]->source) == fmt)
       {
         return 1;
       }
@@ -187,61 +189,61 @@ chain_gen_each (Babl *babl,
   BablChainContext *c = userdata;
 
   /* fill in the conversion for the chain index we are at */
-  c->temp_chain[c->temp_conversions] = (BablConversion*)babl;
+  c->temp_chain[c->temp_conversions] = (BablConversion *) babl;
 
-    {
-      if ((BABL(babl->conversion.destination) == c->to) )
-        {
-          /* a candidate path has been found */
+  {
+    if ((BABL (babl->conversion.destination) == c->to))
+      {
+        /* a candidate path has been found */
 
-          double    temp_cost  = 0.0;
-          double    temp_error = 1.0;
-          int       i;
+        double temp_cost  = 0.0;
+        double temp_error = 1.0;
+        int    i;
 
-          for (i=0; i < c->temp_conversions+1; i++)
-            {
-              temp_error *= (1.0+babl_conversion_error (c->temp_chain[i]));
-              temp_cost  += babl_conversion_cost (c->temp_chain[i]);
-            }
+        for (i = 0; i < c->temp_conversions + 1; i++)
+          {
+            temp_error *= (1.0 + babl_conversion_error (c->temp_chain[i]));
+            temp_cost  += babl_conversion_cost (c->temp_chain[i]);
+          }
 
-          if (temp_cost <  *c->best_cost         &&
-              temp_error - 1.0 <= legal_error()  &&   /* this check before the next; which does a more accurate
+        if (temp_cost < *c->best_cost &&
+            temp_error - 1.0 <= legal_error () &&     /* this check before the next; which does a more accurate
                                                          measurement of the error */
-              (temp_error=chain_error (c->from, c->to, c->temp_chain, c->temp_conversions+1)) <= legal_error()
-             )
-            {
-              int i;
-
-              *c->best_cost   = temp_cost;
-              *c->best_error  = temp_error;
-              *c->conversions = c->temp_conversions + 1;
-
-              /* copy from temp chain to best chain */
-              for (i = 0; i < *c->conversions; i++)
-                 c->chain[i] = c->temp_chain[i];
-            }
-        }
-      else if (babl->conversion.source != babl->conversion.destination &&
-               !chain_contains_fmt (c->temp_chain,
-                                    c->temp_conversions,
-                                    BABL(babl->conversion.destination)))
-        {
-            /* try to add another conversion level in chain,.. */
-            get_conversion_chain (c->from,  /* irrelevant when recalled */
-                                  c->to,
+            (temp_error = chain_error (c->from, c->to, c->temp_chain, c->temp_conversions + 1)) <= legal_error ()
+        )
+          {
+            int i;
+
+            *c->best_cost   = temp_cost;
+            *c->best_error  = temp_error;
+            *c->conversions = c->temp_conversions + 1;
+
+            /* copy from temp chain to best chain */
+            for (i = 0; i < *c->conversions; i++)
+              c->chain[i] = c->temp_chain[i];
+          }
+      }
+    else if (babl->conversion.source != babl->conversion.destination &&
+             !chain_contains_fmt (c->temp_chain,
+                                  c->temp_conversions,
+                                  BABL (babl->conversion.destination)))
+      {
+        /* try to add another conversion level in chain,.. */
+        get_conversion_chain (c->from,      /* irrelevant when recalled */
+                              c->to,
 
-                                  c->best_cost,
-                                  c->best_loss,
-                                  c->best_error,
-                                  c->chain,
-                                  c->conversions,
+                              c->best_cost,
+                              c->best_loss,
+                              c->best_error,
+                              c->chain,
+                              c->conversions,
 
-                                  c->temp_chain,
-                                  c->temp_conversions + 1,
+                              c->temp_chain,
+                              c->temp_conversions + 1,
 
-                                  c->max_conversions);
-        }
-    }
+                              c->max_conversions);
+      }
+  }
   return 0;
 }
 
@@ -249,14 +251,14 @@ static inline Babl *
 assert_conversion_find (void *source,
                         void *destination)
 {
-  int i=0;
+  int    i = 0;
   Babl **conversion;
 
-  conversion = (void*)BABL(source)->type.from;
+  conversion = (void *) BABL (source)->type.from;
   while (conversion && conversion[i])
     {
       if (conversion[i]->conversion.destination == destination)
-        return (Babl*)conversion[i];
+        return (Babl *) conversion[i];
       i++;
     }
   babl_fatal ("failed, aborting");
@@ -271,16 +273,16 @@ create_name (Babl *source,
 {
   /* fish names are intentionally kept short */
   snprintf (buf, 1024, "%s %p %p", "",
-                 source, destination);
+            source, destination);
   return buf;
 }
 
 Babl *
-babl_fish_path (Babl   *source,
-                Babl   *destination)
+babl_fish_path (Babl *source,
+                Babl *destination)
 {
-  Babl *babl = NULL;
-  char *name = create_name (source, destination, 1);
+  Babl           *babl = NULL;
+  char           *name = create_name (source, destination, 1);
   BablConversion *temp_chain[BABL_HARD_MAX_PATH_LENGTH];
 
   babl_assert (BABL_IS_BABL (source));
@@ -289,11 +291,11 @@ babl_fish_path (Babl   *source,
   babl_assert (source->class_type == BABL_FORMAT);
   babl_assert (destination->class_type == BABL_FORMAT);
 
-  babl                   = babl_calloc (1, sizeof (BablFishPath) +
-                                        strlen (name) + 1);
-  babl->class_type       = BABL_FISH_PATH;
-  babl->instance.id      = 0;
-  babl->instance.name    = ((char*)babl) + sizeof(BablFishPath);
+  babl = babl_calloc (1, sizeof (BablFishPath) +
+                      strlen (name) + 1);
+  babl->class_type    = BABL_FISH_PATH;
+  babl->instance.id   = 0;
+  babl->instance.name = ((char *) babl) + sizeof (BablFishPath);
   strcpy (babl->instance.name, name);
   babl->fish.source      = source;
   babl->fish.destination = destination;
@@ -303,9 +305,9 @@ babl_fish_path (Babl   *source,
   babl->fish.usecs       = 0;
   babl->fish.error       = 200000;
 
-  babl->fish_path.cost        = 200000;
-  babl->fish_path.loss        = 200000;
-  babl->fish_path.conversions = 0;
+  babl->fish_path.cost          = 200000;
+  babl->fish_path.loss          = 200000;
+  babl->fish_path.conversions   = 0;
   babl->fish_path.conversion[0] = NULL;
 
   babl_assert (source->class_type == BABL_FORMAT);
@@ -316,13 +318,13 @@ babl_fish_path (Babl   *source,
                         &babl->fish_path.cost,
                         &babl->fish_path.loss,
                         &babl->fish.error,
-                        (BablConversion**)(babl->fish_path.conversion),
+                        (BablConversion **) (babl->fish_path.conversion),
                         &babl->fish_path.conversions,
                         temp_chain,
                         0,
                         max_path_length ());
 
-  if (babl->fish_path.conversions==0)
+  if (babl->fish_path.conversions == 0)
     {
       babl_free (babl);
       return NULL;
@@ -330,8 +332,8 @@ babl_fish_path (Babl   *source,
 
   {
     Babl *ret = babl_db_insert (babl_fish_db (), babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     return ret;
   }
 }
@@ -355,42 +357,42 @@ chain_process (BablConversion *chain[],
   if (conversions > 2)
     bufB = babl_malloc (n * sizeof (double) * 5);
 
-  for (i=0; i<conversions; i++)
+  for (i = 0; i < conversions; i++)
     {
-      if (i==0 && conversions == 1)
+      if (i == 0 && conversions == 1)
         {
-          babl_conversion_process ( BABL(chain[i]),
-              source, destination, n);
+          babl_conversion_process (BABL (chain[i]),
+                                   source, destination, n);
         }
       else if (i == 0)
         {
-          babl_conversion_process ( BABL(chain[i]),
-              source, bufA, n);
+          babl_conversion_process (BABL (chain[i]),
+                                   source, bufA, n);
         }
       else if (i % 2 == 0)
         {
           if (i + 1 == conversions)
             {
-              babl_conversion_process ( BABL(chain[i]),
-                  bufB, destination, n);
+              babl_conversion_process (BABL (chain[i]),
+                                       bufB, destination, n);
             }
           else
             {
-              babl_conversion_process ( BABL(chain[i]),
-                  bufB, bufA, n);
+              babl_conversion_process (BABL (chain[i]),
+                                       bufB, bufA, n);
             }
         }
       else if (i % 2 == 1)
         {
           if (i + 1 == conversions)
             {
-              babl_conversion_process ( BABL(chain[i]),
-                  bufA, destination, n);
+              babl_conversion_process (BABL (chain[i]),
+                                       bufA, destination, n);
             }
           else
             {
-              babl_conversion_process ( BABL(chain[i]),
-                  bufA, bufB, n);
+              babl_conversion_process (BABL (chain[i]),
+                                       bufA, bufB, n);
             }
         }
     }
@@ -406,7 +408,7 @@ long
 babl_fish_path_process (Babl *babl,
                         void *source,
                         void *destination,
-                        long n)
+                        long  n)
 {
   long ret;
 
@@ -423,7 +425,7 @@ babl_fish_path_process (Babl *babl,
 }
 
 
-#define test_pixels   128
+#define test_pixels    128
 
 static double *
 test_create (void)
@@ -436,7 +438,7 @@ test_create (void)
   test = babl_malloc (sizeof (double) * test_pixels * 4);
 
   for (i = 0; i < test_pixels * 4; i++)
-     test [i] = (double) random () / RAND_MAX;
+    test [i] = (double) random () / RAND_MAX;
 
   return test;
 }
@@ -448,43 +450,43 @@ chain_error (Babl            *fmt_source,
              int              conversions)
 {
   Babl *fmt_rgba_double = babl_format_new (
-       babl_model     ("RGBA"),
-       babl_type      ("double"),
-       babl_component ("R"),
-       babl_component ("G"),
-       babl_component ("B"),
-       babl_component ("A"),
-       NULL);
+    babl_model ("RGBA"),
+    babl_type ("double"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
 
-  double   error = 0.0;
+  double  error = 0.0;
 
-  double  *test;
-  void    *source;
-  void    *destination;
-  double  *destination_rgba_double;
-  void    *ref_destination;
-  double  *ref_destination_rgba_double;
+  double *test;
+  void   *source;
+  void   *destination;
+  double *destination_rgba_double;
+  void   *ref_destination;
+  double *ref_destination_rgba_double;
 
-  Babl *fish_rgba_to_source      = babl_fish_reference (fmt_rgba_double, fmt_source);
-  Babl *fish_reference           = babl_fish_reference (fmt_source, fmt_destination);
-  Babl *fish_destination_to_rgba = babl_fish_reference (fmt_destination, fmt_rgba_double);
+  Babl   *fish_rgba_to_source      = babl_fish_reference (fmt_rgba_double, fmt_source);
+  Babl   *fish_reference           = babl_fish_reference (fmt_source, fmt_destination);
+  Babl   *fish_destination_to_rgba = babl_fish_reference (fmt_destination, fmt_rgba_double);
 
-  test=test_create ();
+  test = test_create ();
 
 
-  source          = babl_calloc (test_pixels, fmt_source->format.bytes_per_pixel);
-  destination     = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
-  ref_destination = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
+  source                      = babl_calloc (test_pixels, fmt_source->format.bytes_per_pixel);
+  destination                 = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
+  ref_destination             = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
   destination_rgba_double     = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
   ref_destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
 
- /* create sourcebuffer from testbuffer in the correct format */
 /* create sourcebuffer from testbuffer in the correct format */
   babl_process (fish_rgba_to_source,
-      test, source, test_pixels);
+                test, source, test_pixels);
 
   /* calculate the reference buffer of how it should be */
   babl_process (fish_reference,
-      source, ref_destination, test_pixels);
+                source, ref_destination, test_pixels);
 
   /* calculate this chains view of what the result should be */
   chain_process (chain, conversions, source, destination, test_pixels);
@@ -493,20 +495,20 @@ chain_error (Babl            *fmt_source,
    * for comparison with each other
    */
   babl_process (fish_destination_to_rgba,
-      ref_destination, ref_destination_rgba_double, test_pixels);
+                ref_destination, ref_destination_rgba_double, test_pixels);
   babl_process (fish_destination_to_rgba,
-      destination, destination_rgba_double, test_pixels);
+                destination, destination_rgba_double, test_pixels);
 
   error = babl_rel_avg_error (destination_rgba_double,
                               ref_destination_rgba_double,
-                              test_pixels*4);
+                              test_pixels * 4);
 
   fish_rgba_to_source->fish.processings--;
   fish_reference->fish.processings--;
-  fish_destination_to_rgba->fish.processings-=2;
+  fish_destination_to_rgba->fish.processings -= 2;
 
-  fish_rgba_to_source->fish.pixels -= test_pixels;
-  fish_reference->fish.pixels -= test_pixels;
+  fish_rgba_to_source->fish.pixels      -= test_pixels;
+  fish_reference->fish.pixels           -= test_pixels;
   fish_destination_to_rgba->fish.pixels -= 2 * test_pixels;
 
   babl_free (source);
index 9b62226b160d50616b5b3fe5a4f322afcc9afa15..0a3ecca2e3bcbf37a01b11de299aecf49345bf86 100644 (file)
@@ -38,16 +38,16 @@ create_name (Babl *source,
 {
   /* fish names are intentionally kept short */
   snprintf (buf, 1024, "%s %p %p",
-                 is_reference?"ref "
-                             :"",
-                 source, destination);
+            is_reference ? "ref "
+            "",
+            source, destination);
   return buf;
 }
 
 
 Babl *
-babl_fish_reference (Babl   *source,
-                     Babl   *destination)
+babl_fish_reference (Babl *source,
+                     Babl *destination)
 {
   Babl *babl = NULL;
   char *name = create_name (source, destination, 1);
@@ -58,11 +58,11 @@ babl_fish_reference (Babl   *source,
   babl_assert (source->class_type == BABL_FORMAT);
   babl_assert (destination->class_type == BABL_FORMAT);
 
-  babl                   = babl_malloc (sizeof (BablFishReference) +
-                                        strlen (name) + 1);
-  babl->class_type       = BABL_FISH_REFERENCE;
-  babl->instance.id      = 0;
-  babl->instance.name    = ((char *)babl) + sizeof(BablFishReference);
+  babl = babl_malloc (sizeof (BablFishReference) +
+                      strlen (name) + 1);
+  babl->class_type    = BABL_FISH_REFERENCE;
+  babl->instance.id   = 0;
+  babl->instance.name = ((char *) babl) + sizeof (BablFishReference);
   strcpy (babl->instance.name, name);
   babl->fish.source      = source;
   babl->fish.destination = destination;
@@ -72,10 +72,10 @@ babl_fish_reference (Babl   *source,
   babl->fish.error       = 0.0;  /* assuming the provided reference conversions for types
                                     and models are as exact as possible
                                   */
-  { 
+  {
     Babl *ret = babl_db_insert (babl_fish_db (), babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     return ret;
   }
 }
@@ -88,50 +88,50 @@ convert_to_double (BablFormat *source_fmt,
                    char       *source_double_buf,
                    int         n)
 {
-  int i;
+  int        i;
 
   BablImage *src_img;
   BablImage *dst_img;
-  
-  src_img = (BablImage*) babl_image (
-      babl_component_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
-  dst_img = (BablImage*) babl_image (
-      babl_component_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
-
-  dst_img->type[0]   = (BablType*) babl_type_id (BABL_DOUBLE);
-  dst_img->pitch[0]  =
-             (dst_img->type[0]->bits/8) * source_fmt->model->components;
+
+  src_img = (BablImage *) babl_image (
+    babl_component_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+  dst_img = (BablImage *) babl_image (
+    babl_component_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+
+  dst_img->type[0]  = (BablType *) babl_type_id (BABL_DOUBLE);
+  dst_img->pitch[0] =
+    (dst_img->type[0]->bits / 8) * source_fmt->model->components;
   dst_img->stride[0] = 0;
 
 
   src_img->data[0]   = source_buf;
-  src_img->type[0]   = (BablType*) babl_type_id (BABL_DOUBLE);
+  src_img->type[0]   = (BablType *) babl_type_id (BABL_DOUBLE);
   src_img->pitch[0]  = source_fmt->bytes_per_pixel;
   src_img->stride[0] = 0;
 
   /* i is source position */
-  for (i=0 ; i<source_fmt->components; i++)
+  for (i = 0; i < source_fmt->components; i++)
     {
       int j;
 
       src_img->type[0] = source_fmt->type[i];
       /* j is source position */
-      for (j=0;j<source_fmt->model->components;j++)
+      for (j = 0; j < source_fmt->model->components; j++)
         {
           if (source_fmt->component[i] ==
               source_fmt->model->component[j])
             {
               dst_img->data[0] =
-                       source_double_buf + (dst_img->type[0]->bits/8) * j;
+                source_double_buf + (dst_img->type[0]->bits / 8) * j;
               break;
             }
         }
 
       babl_process (
-           assert_conversion_find (src_img->type[0], dst_img->type[0]),
-           src_img, dst_img,
-           n);
-      src_img->data[0] += src_img->type[0]->bits/8;
+        assert_conversion_find (src_img->type[0], dst_img->type[0]),
+        src_img, dst_img,
+        n);
+      src_img->data[0] += src_img->type[0]->bits / 8;
     }
   babl_free (src_img);
   babl_free (dst_img);
@@ -145,47 +145,47 @@ convert_from_double (BablFormat *destination_fmt,
                      char       *destination_buf,
                      int         n)
 {
-  int i;
+  int        i;
 
   BablImage *src_img;
   BablImage *dst_img;
 
-  src_img = (BablImage*) babl_image (
-      babl_component_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
-  dst_img = (BablImage*) babl_image (
-      babl_component_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+  src_img = (BablImage *) babl_image (
+    babl_component_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+  dst_img = (BablImage *) babl_image (
+    babl_component_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
 
-  src_img->type[0]   = (BablType*) babl_type_id (BABL_DOUBLE);
-  src_img->pitch[0]  = (src_img->type[0]->bits/8) * destination_fmt->model->components;
+  src_img->type[0]   = (BablType *) babl_type_id (BABL_DOUBLE);
+  src_img->pitch[0]  = (src_img->type[0]->bits / 8) * destination_fmt->model->components;
   src_img->stride[0] = 0;
 
-  dst_img->data[0]   = destination_buf;
-  dst_img->type[0]   = (BablType*) babl_type_id (BABL_DOUBLE);
-  dst_img->pitch[0]  = destination_fmt->bytes_per_pixel;
-  dst_img->stride    = 0;
+  dst_img->data[0]  = destination_buf;
+  dst_img->type[0]  = (BablType *) babl_type_id (BABL_DOUBLE);
+  dst_img->pitch[0] = destination_fmt->bytes_per_pixel;
+  dst_img->stride   = 0;
 
-  for (i=0 ; i<destination_fmt->components; i++)
+  for (i = 0; i < destination_fmt->components; i++)
     {
       int j;
 
       dst_img->type[0] = destination_fmt->type[i];
 
-      for (j=0;j<destination_fmt->model->components;j++)
+      for (j = 0; j < destination_fmt->model->components; j++)
         {
           if (destination_fmt->component[i] ==
               destination_fmt->model->component[j])
             {
               src_img->data[0] =
-                  destination_double_buf + (src_img->type[0]->bits/8) * j;
+                destination_double_buf + (src_img->type[0]->bits / 8) * j;
               break;
             }
         }
 
       babl_process (
-           assert_conversion_find (src_img->type[0], dst_img->type[0]),
-           src_img, dst_img,
-           n);
-      dst_img->data[0] += dst_img->type[0]->bits/8;
+        assert_conversion_find (src_img->type[0], dst_img->type[0]),
+        src_img, dst_img,
+        n);
+      dst_img->data[0] += dst_img->type[0]->bits / 8;
     }
   babl_free (src_img);
   babl_free (dst_img);
@@ -196,7 +196,7 @@ static int
 process_same_model (Babl      *babl,
                     BablImage *source,
                     BablImage *destination,
-                    long n)
+                    long       n)
 {
   void *double_buf;
 
@@ -204,27 +204,27 @@ process_same_model (Babl      *babl,
       BABL_IS_BABL (destination))
     {
       babl_log ("args=(%p, %p, %p, %li): trying to handle BablImage (unconfirmed code)",
-                 babl_fish, source, destination, n);
+                babl_fish, source, destination, n);
     }
 
-  double_buf      = babl_malloc(sizeof (double) * n * 
-                              BABL(babl->fish.source)->format.model->components);
+  double_buf = babl_malloc (sizeof (double) * n *
+                            BABL (babl->fish.source)->format.model->components);
 
   convert_to_double (
-     (BablFormat*) BABL(babl->fish.source),
-     BABL_IS_BABL(source)?source:NULL,
-     BABL_IS_BABL(source)?NULL:(char*)source,
-     double_buf,
-     n
-   );
+    (BablFormat *) BABL (babl->fish.source),
+    BABL_IS_BABL (source) ? source : NULL,
+    BABL_IS_BABL (source) ? NULL : (char *) source,
+    double_buf,
+    n
+  );
 
   convert_from_double (
-     (BablFormat*) BABL(babl->fish.destination),
-     double_buf,
-     BABL_IS_BABL(destination)?destination:NULL,
-     BABL_IS_BABL(destination)?NULL:(char*)destination,
-     n
-   );
+    (BablFormat *) BABL (babl->fish.destination),
+    double_buf,
+    BABL_IS_BABL (destination) ? destination : NULL,
+    BABL_IS_BABL (destination) ? NULL : (char *) destination,
+    n
+  );
 
   babl_free (double_buf);
   return 0;
@@ -234,7 +234,7 @@ long
 babl_fish_reference_process (Babl      *babl,
                              BablImage *source,
                              BablImage *destination,
-                             long n)
+                             long       n)
 {
   void *source_double_buf;
   void *rgba_double_buf;
@@ -243,78 +243,78 @@ babl_fish_reference_process (Babl      *babl,
   Babl *rgba_image;
   Babl *destination_image;
 
-  if (BABL(babl->fish.source)->format.model ==
-      BABL(babl->fish.destination)->format.model)
-        return process_same_model (babl, source, destination, n); 
+  if (BABL (babl->fish.source)->format.model ==
+      BABL (babl->fish.destination)->format.model)
+    return process_same_model (babl, source, destination, n);
 #if 0
   if (BABL_IS_BABL (source) ||
       BABL_IS_BABL (destination))
     {
       babl_log ("args=(%p, %p, %p, %li): trying to handle BablImage (unconfirmed code)",
-                 babl_fish, source, destination, n);
+                babl_fish, source, destination, n);
     }
 #endif
 
-  source_double_buf      = babl_malloc(sizeof (double) * n * 
-                              BABL(babl->fish.source)->format.model->components);
-  rgba_double_buf        = babl_malloc(sizeof (double) * n * 4);
-  destination_double_buf = babl_malloc(sizeof (double) * n *
-                              BABL(babl->fish.destination)->format.model->components);
+  source_double_buf = babl_malloc (sizeof (double) * n *
+                                   BABL (babl->fish.source)->format.model->components);
+  rgba_double_buf        = babl_malloc (sizeof (double) * n * 4);
+  destination_double_buf = babl_malloc (sizeof (double) * n *
+                                        BABL (babl->fish.destination)->format.model->components);
 
-  source_image      = babl_image_from_linear (
-      source_double_buf,BABL(BABL((babl->fish.source)) -> format.model));
-  rgba_image        = babl_image_from_linear (
-      rgba_double_buf, babl_model_id (BABL_RGBA));
+  source_image = babl_image_from_linear (
+    source_double_buf, BABL (BABL ((babl->fish.source))->format.model));
+  rgba_image = babl_image_from_linear (
+    rgba_double_buf, babl_model_id (BABL_RGBA));
   destination_image = babl_image_from_linear (
-      destination_double_buf, BABL(BABL((babl->fish.destination))->format.model));
+    destination_double_buf, BABL (BABL ((babl->fish.destination))->format.model));
 
   convert_to_double (
-     (BablFormat*) BABL(babl->fish.source),
-     NULL,
-     (char*)source,
-     source_double_buf,
-     n
-   );
+    (BablFormat *) BABL (babl->fish.source),
+    NULL,
+    (char *) source,
+    source_double_buf,
+    n
+  );
 
   {
     Babl *conv =
-    assert_conversion_find (
-        BABL(babl->fish.source)->format.model,
-        babl_model_id (BABL_RGBA)
-    );
+      assert_conversion_find (
+      BABL (babl->fish.source)->format.model,
+      babl_model_id (BABL_RGBA)
+      );
     if (conv->class_type == BABL_CONVERSION_PLANAR)
       {
         babl_process (
-         conv,
+          conv,
           source_image, rgba_image,
           n);
       }
     else if (conv->class_type == BABL_CONVERSION_LINEAR)
       {
         babl_process (
-         conv,
-         source_double_buf, rgba_double_buf,
-         n);
+          conv,
+          source_double_buf, rgba_double_buf,
+          n);
       }
     else babl_fatal ("oops");
   }
 
   {
     Babl *conv =
-    assert_conversion_find (
-        babl_model_id (BABL_RGBA),
-        BABL(babl->fish.destination)->format.model);
+      assert_conversion_find (
+      babl_model_id (BABL_RGBA),
+      BABL (babl->fish.destination)->format.model);
     if (conv->class_type == BABL_CONVERSION_PLANAR)
       {
         babl_process (
-         conv,
+          conv,
           rgba_image, destination_image,
           n);
       }
     else if (conv->class_type == BABL_CONVERSION_LINEAR)
       {
         babl_process (
-         conv,
+          conv,
           rgba_double_buf, destination_double_buf,
           n);
       }
@@ -322,12 +322,12 @@ babl_fish_reference_process (Babl      *babl,
   }
 
   convert_from_double (
-     (BablFormat*) BABL(babl->fish.destination),
-     destination_double_buf,
-     NULL,
-     (char*)destination,
-     n
-   );
+    (BablFormat *) BABL (babl->fish.destination),
+    destination_double_buf,
+    NULL,
+    (char *) destination,
+    n
+  );
 
   babl_free (source_image);
   babl_free (rgba_image);
index 26249f7feed8ae3179f8d9312741f2ff7c144c93..72fbb8c793df5991586ec17f50b007a6016cd34d 100644 (file)
@@ -33,28 +33,28 @@ babl_fish_simple (BablConversion *conversion)
 
   babl_assert (BABL_IS_BABL (conversion));
 
-  name  = create_name (conversion);
+  name = create_name (conversion);
 
-  babl                   = babl_malloc (sizeof (BablFishSimple) +
-                                        strlen (name) + 1);
-  babl->class_type       = BABL_FISH_SIMPLE;
-  babl->instance.id      = 0;
-  babl->instance.name    = ((char *)babl) + sizeof(BablFishSimple);
+  babl = babl_malloc (sizeof (BablFishSimple) +
+                      strlen (name) + 1);
+  babl->class_type    = BABL_FISH_SIMPLE;
+  babl->instance.id   = 0;
+  babl->instance.name = ((char *) babl) + sizeof (BablFishSimple);
   strcpy (babl->instance.name, name);
   babl->fish.source      = conversion->source;
   babl->fish.destination = conversion->destination;
 
-  babl->fish.processings = 0;
-  babl->fish.pixels      = 0;
+  babl->fish.processings       = 0;
+  babl->fish.pixels            = 0;
   babl->fish_simple.conversion = conversion;
-  babl->fish.error       = 0.0; /* babl fish simple should only be used by bablfish
+  babl->fish.error             = 0.0;/* babl fish simple should only be used by bablfish
                                    reference, and babl fish reference only requests clean
                                    conversions */
 
-  { 
+  {
     Babl *ret = babl_db_insert (babl_fish_db (), babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     return ret;
   }
 }
index 66403a2f35f86759afe9651a9e63e1279ee5a1d7..485b783b9452c00524eaa31591503cf5d780f6af 100644 (file)
@@ -20,9 +20,9 @@
 #include "babl-internal.h"
 
 static FILE *output_file = NULL;
-static int qux=0;
+static int   qux         = 0;
 
-static char *utf8_bar[]={" ","·","▁","▂","▃","▄","▅","▆","▇","█"};
+static char *utf8_bar[] = { " ", "·", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" };
 //static char *utf8_bar[]=  {"!","▁","▃","▅","▇","█","!","!","!"};
 //static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁", };
 //static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"};
@@ -31,11 +31,11 @@ static int
 table_destination_each (Babl *babl,
                         void *userdata)
 {
-  Babl *source = userdata;
+  Babl *source      = userdata;
   Babl *destination = babl;
 
-  if ((qux++) % babl_formats_count () == qux/ babl_formats_count ())
-     fprintf (output_file, "<td class='cell'>&nbsp;</td>");
+  if ((qux++) % babl_formats_count () == qux / babl_formats_count ())
+    fprintf (output_file, "<td class='cell'>&nbsp;</td>");
   else
     {
       Babl *fish = babl_fish (source, destination);
@@ -48,8 +48,8 @@ table_destination_each (Babl *babl,
           case BABL_FISH_PATH:
 
             fprintf (output_file, "<td class='cell'%s><a href='javascript:o()'>%s",
-               fish->fish.processings > 0 ? " style='background-color: #69f'":"",
-            utf8_bar[fish->fish_path.conversions]);
+                     fish->fish.processings > 0 ? " style='background-color: #69f'" : "",
+                     utf8_bar[fish->fish_path.conversions]);
 
             {
               int i;
@@ -63,47 +63,49 @@ table_destination_each (Babl *babl,
                 }
               fprintf (output_file, "<table>\n");
 
-                  fprintf (output_file, "<tr>");
-                  fprintf (output_file, "<td><em>conversion</em></td>");
-                  fprintf (output_file, "<td style='text-align:right'><em>cost</em></td>");
-                  fprintf (output_file, "<td style='text-align:right'><em>error</em></td>");
-                  fprintf (output_file, "</tr>");
+              fprintf (output_file, "<tr>");
+              fprintf (output_file, "<td><em>conversion</em></td>");
+              fprintf (output_file, "<td style='text-align:right'><em>cost</em></td>");
+              fprintf (output_file, "<td style='text-align:right'><em>error</em></td>");
+              fprintf (output_file, "</tr>");
 
-               for (i=0; i< fish->fish_path.conversions; i++)
-                 {
+              for (i = 0; i < fish->fish_path.conversions; i++)
+                {
                   fprintf (output_file, "<tr>");
-                  fprintf (output_file, "<td>%s</td>", BABL(fish->fish_path.conversion[i])->instance.name);
-                  fprintf (output_file, "<td class='r'>%li</td>", babl_conversion_cost (&BABL(fish->fish_path.conversion[i])->conversion));
-                  fprintf (output_file, "<td class='r'>%e</td>", babl_conversion_error (&BABL(fish->fish_path.conversion[i])->conversion));
+                  fprintf (output_file, "<td>%s</td>", BABL (fish->fish_path.conversion[i])->instance.name);
+                  fprintf (output_file, "<td class='r'>%li</td>", babl_conversion_cost (&BABL (fish->fish_path.conversion[i])->conversion));
+                  fprintf (output_file, "<td class='r'>%e</td>", babl_conversion_error (&BABL (fish->fish_path.conversion[i])->conversion));
                   fprintf (output_file, "</tr>");
-                 }
+                }
 
-                  fprintf (output_file, "<tr>");
-                  fprintf (output_file, "<td><em>total</em></td>");
-                  fprintf (output_file, "<td class='r'><em>%3.0f</em></td>", fish->fish_path.cost);
-                  fprintf (output_file, "<td class='r'><em>%e</em></td>", fish->fish.error);
-                  fprintf (output_file, "</tr>");
+              fprintf (output_file, "<tr>");
+              fprintf (output_file, "<td><em>total</em></td>");
+              fprintf (output_file, "<td class='r'><em>%3.0f</em></td>", fish->fish_path.cost);
+              fprintf (output_file, "<td class='r'><em>%e</em></td>", fish->fish.error);
+              fprintf (output_file, "</tr>");
               fprintf (output_file, "</table>");
               fprintf (output_file, "</div>");
             }
             fprintf (output_file, "</a></td>\n");
             break;
+
           case BABL_FISH_REFERENCE:
             fprintf (output_file, "<td class='cell'%s><a href='javascript:o()'>&nbsp",
-               fish->fish.processings > 0 ? " style='background-color: #69f'":"");
+                     fish->fish.processings > 0 ? " style='background-color: #69f'" : "");
             fprintf (output_file, "<div class='tooltip'>");
             fprintf (output_file, "<h3><span class='g'>Reference</span> %s <span class='g'>to</span> %s</h3>", source->instance.name, destination->instance.name);
 
-              if (fish->fish.processings > 0)
-                {
-                  fprintf (output_file, "<span class='g'>usecs:</span>%li<br/>", fish->fish.usecs);
-                  fprintf (output_file, "<span class='g'>Processings:</span>%i<br/>", fish->fish.processings);
-                  fprintf (output_file, "<span class='g'>Pixels:</span>%li<br/>", fish->fish.pixels);
-                }
+            if (fish->fish.processings > 0)
+              {
+                fprintf (output_file, "<span class='g'>usecs:</span>%li<br/>", fish->fish.usecs);
+                fprintf (output_file, "<span class='g'>Processings:</span>%i<br/>", fish->fish.processings);
+                fprintf (output_file, "<span class='g'>Pixels:</span>%li<br/>", fish->fish.pixels);
+              }
             fprintf (output_file, "</div>");
             fprintf (output_file, "</a></td>\n");
             break;
-         default:
+
+          default:
             babl_assert (0);
             break;
         }
@@ -111,36 +113,37 @@ table_destination_each (Babl *babl,
   return 0;
 }
 
-static int source_no=0;
+static int source_no = 0;
 
 static int
 table_source_each (Babl *babl,
                    void *userdata)
 {
-  char expanded_name[512];
+  char        expanded_name[512];
   const char *s;
-  char *d;
+  char       *d;
 
-  s=babl->instance.name;
-  d=&expanded_name[0];
+  s = babl->instance.name;
+  d = &expanded_name[0];
 
   while (*s)
     {
       switch (*s)
         {
           case ' ':
-            *(d++)='&';
-            *(d++)='n';
-            *(d++)='b';
-            *(d++)='s';
-            *(d++)='p';
-            *(d++)=';';
-            *(d)  ='\0';
+            *(d++) = '&';
+            *(d++) = 'n';
+            *(d++) = 'b';
+            *(d++) = 's';
+            *(d++) = 'p';
+            *(d++) = ';';
+            *(d)   = '\0';
             s++;
             break;
+
           default:
-            *(d++)=*(s++);
-            *(d)  ='\0';
+            *(d++) = *(s++);
+            *(d)   = '\0';
             break;
         }
     }
@@ -155,15 +158,15 @@ table_source_each (Babl *babl,
 
     fprintf (output_file, "<dl>");
     fprintf (output_file, "<dt>bytes/pixel</dt><dd>%i</dd>", babl->format.bytes_per_pixel);
-    fprintf (output_file, "<dt>model</dt><dd>%s</dd>", BABL(babl->format.model)->instance.name  );
+    fprintf (output_file, "<dt>model</dt><dd>%s</dd>", BABL (babl->format.model)->instance.name);
     fprintf (output_file, "<dt>loss</dt><dd>%f</dd>", babl_format_loss (babl));
     fprintf (output_file, "<dt>components</dt><dd><table class='nopad'>");
 
-    for (i=0; i< babl->format.components; i++)
+    for (i = 0; i < babl->format.components; i++)
       {
         fprintf (output_file, "<tr><td class='type'>%s</td><td class='component'>%s</td></tr>",
-         BABL(babl->format.type[i])->instance.name,
-         BABL(babl->format.component[i])->instance.name  );
+                 BABL (babl->format.type[i])->instance.name,
+                 BABL (babl->format.component[i])->instance.name);
       }
     fprintf (output_file, "</table></dd></dl>");
 
@@ -183,13 +186,13 @@ each_conv (Babl *babl,
 {
   double error, cost;
 
-  if (BABL(babl->conversion.source)->class_type != BABL_FORMAT)
+  if (BABL (babl->conversion.source)->class_type != BABL_FORMAT)
     return 0;
 
   error = babl_conversion_error (&babl->conversion);
-  cost  = babl_conversion_cost  (&babl->conversion);
+  cost  = babl_conversion_cost (&babl->conversion);
 
-  if (error>0.01)
+  if (error > 0.01)
     {
       fprintf (output_file, "<dt style='background-color: #fcc;'>%s</dt>", babl->instance.name);
       fprintf (output_file, "<dd style='background-color: #fcc;'>");
@@ -199,7 +202,7 @@ each_conv (Babl *babl,
       fprintf (output_file, "<dt>%s</dt><dd>", babl->instance.name);
     }
   fprintf (output_file, "<em>error:</em> %f <em>cost:</em> %4.0f <em>processings:</em> %i <em>pixels:</em> %li", error, cost,
-            babl->conversion.processings, babl->conversion.pixels);
+           babl->conversion.processings, babl->conversion.pixels);
   fprintf (output_file, "</dd>");
 
   return 0;
@@ -219,121 +222,121 @@ babl_fish_stats (FILE *file)
   output_file = file;
 
   fprintf (output_file,
-"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
-"<html>\n"
-"<head>\n"
-"<title>BablFishPath introspection</title>\n"
-
-   "<style type='text/css'>"
-   " body {"
-   "   font-family: sans;"
-   "   margin-left: 1em;"
-   " }"
-   " .cell {"
-   "  overflow : none;"
-   "  height: 1em;"
-   "  font-family: monospace;"
-   "  border: 1px solid #eee;"
-   "  padding: 0;"
-   "  margin : 0;"
-   "}"
-   ".cell>a {"
-   "    text-decoration: none;"
-   "    color: black;"
-   "    cursor: help;"
-   "}"
-   "div.tooltip {"
-   "   border: 0.2em solid black;"
-   "   padding-top: 1em;"
-   "   padding-right: 2em;"
-   "   display: none;"
-   "   padding-left: 2em;"
-   "   padding-bottom: 3em;"
-   "   background-color: white;"
-   "   background-repeat: no-repeat;"
-   "   background-image: url(graphics/babl-48x48.png);"
-   "   background-position: bottom right;"
-   "   color: black;"
-   "}"
-   " .cell>a:hover {"
-   "  background-color: black;"
-   "  color: white;"
-   "}"
-   " .format_name {"
-   "  height: 1em;"
-   "  background-color: #eee;"
-   "  padding-right: 0.5em;"
-   "  padding-left:  0.5em;"
-   "  border-bottom: 1px solid #fff;"
-   "}"
-   " .format_name>a {"
-   "  text-decoration: none;"
-   "  color: blue;"
-   "    cursor: help;"
-   " }"
-   " .format_name>a:hover {"
-   "  background-color: blue;"
-   "  color: white;"
-   " }"
-
-   "a:hover>div.tooltip {"
-   "   display: block;"
-   "   position: fixed;"
-   "   bottom: 0;"
-   "   right: 0;"
-   "}"
-
-   "td.component {"
-   "  background-color: #060;"
-   "  padding-left: 0.5em;"
-   "  padding-top: 0.1em;"
-   "  padding-bottom: 0.1em;"
-   "  overflow: hidden;"
-   "  width: 4em;"
-   "  color: white;"
-   "  border: 1px solid white;"
-   "}"
-   "td.type {"
-   "  background-color: #006;"
-   "  padding-left: 0.5em;"
-   "  padding-top: 0.1em;"
-   "  padding-bottom: 0.1em;"
-   "  overflow: hidden;"
-   "  width: 4em;"
-   "  color: white;"
-   "  border: 1px solid white;"
-   "}"
-   ".g {"
-   "  color: gray;"
-   "}"
-   ".r {"
-   "  text-align: right;"
-   "}"
-
-   "</style>"
-
-"<script type='text/javascript'>"
-"var tick_count=0;"
-"function o ()"
-"{"
-"   tick_count++;"
-"   if (tick_count == 11)"
-"        alert(\"«The mind is it's own place,\\nand in itself can make a heaven of hell;\\na hell of heaven.»\\n--Milton\");"
-"   else if (tick_count == 42)"
-"        alert(\"«So long and thanks for all the fish.»\\n--Adams\");"
-"}"
-"</script>"
-
-
-"</head>\n");
-
-  fprintf (output_file,  "<body>\n");
+           "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+           "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
+           "<html>\n"
+           "<head>\n"
+           "<title>BablFishPath introspection</title>\n"
+
+           "<style type='text/css'>"
+           " body {"
+           "   font-family: sans;"
+           "   margin-left: 1em;"
+           " }"
+           " .cell {"
+           "  overflow : none;"
+           "  height: 1em;"
+           "  font-family: monospace;"
+           "  border: 1px solid #eee;"
+           "  padding: 0;"
+           "  margin : 0;"
+           "}"
+           ".cell>a {"
+           "    text-decoration: none;"
+           "    color: black;"
+           "    cursor: help;"
+           "}"
+           "div.tooltip {"
+           "   border: 0.2em solid black;"
+           "   padding-top: 1em;"
+           "   padding-right: 2em;"
+           "   display: none;"
+           "   padding-left: 2em;"
+           "   padding-bottom: 3em;"
+           "   background-color: white;"
+           "   background-repeat: no-repeat;"
+           "   background-image: url(graphics/babl-48x48.png);"
+           "   background-position: bottom right;"
+           "   color: black;"
+           "}"
+           " .cell>a:hover {"
+           "  background-color: black;"
+           "  color: white;"
+           "}"
+           " .format_name {"
+           "  height: 1em;"
+           "  background-color: #eee;"
+           "  padding-right: 0.5em;"
+           "  padding-left:  0.5em;"
+           "  border-bottom: 1px solid #fff;"
+           "}"
+           " .format_name>a {"
+           "  text-decoration: none;"
+           "  color: blue;"
+           "    cursor: help;"
+           " }"
+           " .format_name>a:hover {"
+           "  background-color: blue;"
+           "  color: white;"
+           " }"
+
+           "a:hover>div.tooltip {"
+           "   display: block;"
+           "   position: fixed;"
+           "   bottom: 0;"
+           "   right: 0;"
+           "}"
+
+           "td.component {"
+           "  background-color: #060;"
+           "  padding-left: 0.5em;"
+           "  padding-top: 0.1em;"
+           "  padding-bottom: 0.1em;"
+           "  overflow: hidden;"
+           "  width: 4em;"
+           "  color: white;"
+           "  border: 1px solid white;"
+           "}"
+           "td.type {"
+           "  background-color: #006;"
+           "  padding-left: 0.5em;"
+           "  padding-top: 0.1em;"
+           "  padding-bottom: 0.1em;"
+           "  overflow: hidden;"
+           "  width: 4em;"
+           "  color: white;"
+           "  border: 1px solid white;"
+           "}"
+           ".g {"
+           "  color: gray;"
+           "}"
+           ".r {"
+           "  text-align: right;"
+           "}"
+
+           "</style>"
+
+           "<script type='text/javascript'>"
+           "var tick_count=0;"
+           "function o ()"
+           "{"
+           "   tick_count++;"
+           "   if (tick_count == 11)"
+           "        alert(\"«The mind is it's own place,\\nand in itself can make a heaven of hell;\\na hell of heaven.»\\n--Milton\");"
+           "   else if (tick_count == 42)"
+           "        alert(\"«So long and thanks for all the fish.»\\n--Adams\");"
+           "}"
+           "</script>"
+
+
+           "</head>\n");
+
+  fprintf (output_file, "<body>\n");
 
   fprintf (output_file, "<h1>BablFishPath introspection</h1>");
   fprintf (output_file, "<p>Instrumentation and pathlengths.</p>");
 
-  fprintf (output_file,  "<table cellspacing='0'><tr><td>Source format</td><td colspan='32'>Destination formats</td></tr>\n");
+  fprintf (output_file, "<table cellspacing='0'><tr><td>Source format</td><td colspan='32'>Destination formats</td></tr>\n");
 
   babl_format_each (table_source_each, NULL);
 
index 5675ea8edf4e09640389786efc4305b4c76663b5..515ea162ab3b5cab665bf9c8ffb4c4ead3ed841c 100644 (file)
 
 
 static int
-match_conversion (Babl  *conversion,
-                  void  *inout)
+match_conversion (Babl *conversion,
+                  void *inout)
 {
   void **data = inout;
 
-  if ((Babl *) conversion->conversion.destination == (Babl*) *data)
+  if ((Babl *) conversion->conversion.destination == (Babl *) *data)
     {
-      *data = (void *)conversion;
+      *data = (void *) conversion;
       return 1;
     }
   return 0;
@@ -40,9 +40,9 @@ Babl *
 babl_conversion_find (void *source,
                       void *destination)
 {
-  void *data=destination;
+  void *data = destination;
 
-  babl_list_each ((void*)BABL(source)->type.from, match_conversion, &data);
+  babl_list_each ((void *) BABL (source)->type.from, match_conversion, &data);
   if (data == destination)
     return NULL;
   return data;
@@ -63,31 +63,31 @@ typedef struct BablFishingData
   Babl *ret;
 } BablFishingData;
 
-static int 
+static int
 fishing_result_examine (Babl *babl,
                         void *void_data)
 {
   BablFishingData *data = void_data;
 
-  if ((void*)data->source == (void*)babl->fish.source &&
-      (void*)data->destination == (void*)babl->fish.destination)
+  if ((void *) data->source == (void *) babl->fish.source &&
+      (void *) data->destination == (void *) babl->fish.destination)
     {
-          data->ret = babl;
-          return 1; /* stop iterating */
+      data->ret = babl;
+      return 1;     /* stop iterating */
     }
   return 0;  /* continue iterating */
 }
 
-static Babl * 
-go_fishing (Babl    *source,
-            Babl    *destination)
+static Babl *
+go_fishing (Babl *source,
+            Babl *destination)
 {
   {
     BablFishingData data;
 
-    data.source = source;
+    data.source      = source;
     data.destination = destination;
-    data.ret = NULL;
+    data.ret         = NULL;
 
     babl_db_each (db, fishing_result_examine, &data);
     return data.ret;
@@ -112,7 +112,7 @@ babl_fish (void *source,
 
   if (!source_format)
     {
-      source_format = babl_format ((char*)source);
+      source_format = babl_format ((char *) source);
     }
 
   if (!source_format)
@@ -128,7 +128,7 @@ babl_fish (void *source,
 
   if (!destination_format)
     {
-      destination_format = babl_format ((char*)destination);
+      destination_format = babl_format ((char *) destination);
     }
 
   if (!destination_format)
@@ -137,34 +137,34 @@ babl_fish (void *source,
       return NULL;
     }
 
-    {
-  Babl *lucky;
-  lucky = go_fishing (source_format, destination_format);
-  if (lucky)
-    return lucky;
-    }
+  {
+    Babl *lucky;
+    lucky = go_fishing (source_format, destination_format);
+    if (lucky)
+      return lucky;
+  }
+
   if (0)
     {
-    Babl *shortcut_conversion;
-   
-    shortcut_conversion = babl_conversion_find (
-                                  source_format, destination_format);
+      Babl *shortcut_conversion;
 
-    if (shortcut_conversion)
-      {
-        return babl_fish_simple (&(shortcut_conversion->conversion));
-      }
-  }
+      shortcut_conversion = babl_conversion_find (
+        source_format, destination_format);
+
+      if (shortcut_conversion)
+        {
+          return babl_fish_simple (&(shortcut_conversion->conversion));
+        }
+    }
 
   {
     Babl *fish_path;
-   
+
     fish_path = babl_fish_path (source_format, destination_format);
 
     if (fish_path)
       {
-         return fish_path;
+        return fish_path;
       }
   }
 
@@ -179,7 +179,7 @@ babl_fish_process (Babl *babl,
 {
   BablImage *source_image      = NULL;
   BablImage *destination_image = NULL;
-  long ret=0;
+  long       ret               = 0;
 
   switch (babl->class_type)
     {
@@ -188,45 +188,46 @@ babl_fish_process (Babl *babl,
       case BABL_FISH_PATH:
 
 #if 0
-         if (BABL_IS_BABL (source))
-           source_image = source;
+        if (BABL_IS_BABL (source))
+          source_image = source;
 #endif
-         if (!source_image)
-           source_image = (BablImage*) babl_image_from_linear (
-                                          source, (Babl*)babl->fish.source);
+        if (!source_image)
+          source_image = (BablImage *) babl_image_from_linear (
+            source, (Babl *) babl->fish.source);
 #if 0
-         if (BABL_IS_BABL (destination))
-           destination_image = destination;
+        if (BABL_IS_BABL (destination))
+          destination_image = destination;
 #endif
-         if (!destination_image)
-           destination_image = (BablImage*) babl_image_from_linear (
-                          destination, (Babl*)babl->fish.destination);
-
-         if (babl->class_type == BABL_FISH_REFERENCE)
-           {
-             ret = babl_fish_reference_process (babl, source, destination, n);
-           }
-         else if (babl->class_type == BABL_FISH_PATH)
-           {
-             ret = babl_fish_path_process (babl, source, destination, n);
-           }
-         else if (babl->class_type == BABL_FISH_SIMPLE)
-           { 
-             if (BABL(babl->fish_simple.conversion)->class_type==BABL_CONVERSION_LINEAR)
-               {
-                 ret = babl_conversion_process (BABL(babl->fish_simple.conversion),
-                                                source, destination, n);
-               }
-             else
-               {
-                 ret = babl_conversion_process (BABL(babl->fish_simple.conversion),
-                                              (char*)source_image, (char*)destination_image, n);
-               }
-           }
+        if (!destination_image)
+          destination_image = (BablImage *) babl_image_from_linear (
+            destination, (Babl *) babl->fish.destination);
+
+        if (babl->class_type == BABL_FISH_REFERENCE)
+          {
+            ret = babl_fish_reference_process (babl, source, destination, n);
+          }
+        else if (babl->class_type == BABL_FISH_PATH)
+          {
+            ret = babl_fish_path_process (babl, source, destination, n);
+          }
+        else if (babl->class_type == BABL_FISH_SIMPLE)
+          {
+            if (BABL (babl->fish_simple.conversion)->class_type == BABL_CONVERSION_LINEAR)
+              {
+                ret = babl_conversion_process (BABL (babl->fish_simple.conversion),
+                                               source, destination, n);
+              }
+            else
+              {
+                ret = babl_conversion_process (BABL (babl->fish_simple.conversion),
+                                               (char *) source_image, (char *) destination_image, n);
+              }
+          }
 
         babl_free (source_image);
         babl_free (destination_image);
         break;
+
       default:
         babl_log ("NYI");
         ret = -1;
@@ -236,7 +237,7 @@ babl_fish_process (Babl *babl,
   return ret;
 }
 
-static int 
+static int
 each_babl_fish_destroy (Babl *babl,
                         void *data)
 {
@@ -244,6 +245,6 @@ each_babl_fish_destroy (Babl *babl,
   return 0;  /* continue iterating */
 }
 
-BABL_DEFINE_INIT    (fish)
+BABL_DEFINE_INIT (fish)
 BABL_DEFINE_DESTROY (fish)
-BABL_DEFINE_EACH    (fish)
+BABL_DEFINE_EACH (fish)
index 149e61a9cbe0ecfb5278fcc6976de3379dfd94c7..9d46604ed11d9e8188d5ad32441f89124dae2d01 100644 (file)
@@ -24,7 +24,7 @@
 #include "babl-internal.h"
 #include "babl-db.h"
 
-static int 
+static int
 each_babl_format_destroy (Babl *babl,
                           void *data)
 {
@@ -49,56 +49,56 @@ format_new (const char     *name,
   {
     int i;
     /* i is desintation position */
-    for (i=0 ; i<model->components; i++)
+    for (i = 0; i < model->components; i++)
       {
         int j;
 
-        for (j=0;j<components;j++)
+        for (j = 0; j < components; j++)
           {
             if (component[j] == model->component[i])
               goto component_found;
           }
         babl_fatal ("matching source component for %s in model %s not found",
                     model->component[i]->instance.name, model->instance.name);
-        component_found:
+component_found:
         ;
       }
   }
 
   /* allocate all memory in one chunk */
-  babl  = babl_malloc (sizeof (BablFormat) +
-                       strlen (name) + 1 +
-                       sizeof (BablComponent*) * (components) +
-                       sizeof (BablSampling*)  * (components) +
-                       sizeof (BablType*)      * (components) +
-                       sizeof (int)            * (components) +
-                       sizeof (int)            * (components));
+  babl = babl_malloc (sizeof (BablFormat) +
+                      strlen (name) + 1 +
+                      sizeof (BablComponent *) * (components) +
+                      sizeof (BablSampling *) * (components) +
+                      sizeof (BablType *) * (components) +
+                      sizeof (int) * (components) +
+                      sizeof (int) * (components));
 
   babl->format.from      = NULL;
-  babl->format.component = (void*)(((char *)babl) + sizeof (BablFormat));
-  babl->format.type      = (void*)(((char *)babl->format.component) + sizeof (BablComponent*) * (components));
-  babl->format.sampling  = (void*)(((char *)babl->format.type)      + sizeof (BablType*) * (components));
-  babl->instance.name    = ((char *)babl->format.sampling)  + sizeof (BablSampling*) * (components);
-  
-  babl->class_type    = BABL_FORMAT;
-  babl->instance.id   = id;
+  babl->format.component = (void *) (((char *) babl) + sizeof (BablFormat));
+  babl->format.type      = (void *) (((char *) babl->format.component) + sizeof (BablComponent *) * (components));
+  babl->format.sampling  = (void *) (((char *) babl->format.type) + sizeof (BablType *) * (components));
+  babl->instance.name    = ((char *) babl->format.sampling) + sizeof (BablSampling *) * (components);
+
+  babl->class_type  = BABL_FORMAT;
+  babl->instance.id = id;
 
   strcpy (babl->instance.name, name);
 
   babl->format.model      = model;
   babl->format.components = components;
 
-  memcpy (babl->format.component, component, sizeof (BablComponent*) * components);
-  memcpy (babl->format.type     , type     , sizeof (BablType*)      * components);
-  memcpy (babl->format.sampling , sampling , sizeof (BablSampling*)  * components);
+  memcpy (babl->format.component, component, sizeof (BablComponent *) * components);
+  memcpy (babl->format.type, type, sizeof (BablType *) * components);
+  memcpy (babl->format.sampling, sampling, sizeof (BablSampling *) * components);
 
-  babl->format.planar     = planar;
+  babl->format.planar = planar;
 
   babl->format.bytes_per_pixel = 0;
   {
     int i;
-    for (i=0;i<components;i++)
-      babl->format.bytes_per_pixel += type[i]->bits/8;
+    for (i = 0; i < components; i++)
+      babl->format.bytes_per_pixel += type[i]->bits / 8;
   }
 
   babl->format.loss = -1.0;
@@ -107,7 +107,7 @@ format_new (const char     *name,
 }
 
 
-static char buf[512]="";
+static char buf[512] = "";
 
 static const char *
 create_name (BablModel      *model,
@@ -115,39 +115,39 @@ create_name (BablModel      *model,
              BablComponent **component,
              BablType      **type)
 {
-  char *p = &buf[0];
-  int   i;
-  int   same_types=1;
-  BablType **t=type;
-  BablType *first_type = *type;
-  BablComponent **c1=component;
-  BablComponent **c2=model->component;
-
-  
+  char           *p = &buf[0];
+  int             i;
+  int             same_types = 1;
+  BablType      **t          = type;
+  BablType       *first_type = *type;
+  BablComponent **c1         = component;
+  BablComponent **c2         = model->component;
+
+
   sprintf (p, "%s ", model->instance.name);
-  p+=strlen (model->instance.name) + 1;
+  p += strlen (model->instance.name) + 1;
 
-  i=components;
+  i = components;
   while (i--)
     {
       if (first_type != *t)
         {
-          same_types=0;
+          same_types = 0;
           break;
         }
       t++;
     }
 
-  if (same_types && 
+  if (same_types &&
       components != model->components)
     same_types = 0;
-  
-  i=components;
+
+  i = components;
   while (same_types && i--)
     {
       if (*c1 != *c2)
         {
-          same_types=0;
+          same_types = 0;
           break;
         }
       c1++;
@@ -161,15 +161,15 @@ create_name (BablModel      *model,
       return buf;
     }
 
-  i=components;
+  i = components;
 
   while (i--)
     {
-      sprintf (p, "(%s as %s) ", 
-         (*component)->instance.name,
-         (*type)->instance.name);
-      p+=strlen ((*component)->instance.name) +
-         strlen ((*type)->instance.name     ) + strlen("( as ) ");
+      sprintf (p, "(%s as %s) ",
+               (*component)->instance.name,
+               (*type)->instance.name);
+      p += strlen ((*component)->instance.name) +
+           strlen ((*type)->instance.name) + strlen ("( as ) ");
       component++;
       type++;
     }
@@ -180,64 +180,68 @@ Babl *
 babl_format_new (void *first_arg,
                  ...)
 {
-  va_list varg;
-  Babl            *babl;
-  int              id     = 0;
-  int              planar = 0;
-  int              components  = 0;
-  BablModel       *model  = NULL;
-  BablComponent   *component [BABL_MAX_COMPONENTS];
-  BablSampling    *sampling  [BABL_MAX_COMPONENTS];
-  BablType        *type      [BABL_MAX_COMPONENTS];
-
-  BablSampling    *current_sampling = (BablSampling*) babl_sampling (1,1);
-  BablType        *current_type     = (BablType*)     babl_type_id (BABL_DOUBLE);
-  char            *name             = NULL;
-  void            *arg              = first_arg;
+  va_list        varg;
+  Babl          *babl;
+  int            id         = 0;
+  int            planar     = 0;
+  int            components = 0;
+  BablModel     *model      = NULL;
+  BablComponent *component [BABL_MAX_COMPONENTS];
+  BablSampling  *sampling  [BABL_MAX_COMPONENTS];
+  BablType      *type      [BABL_MAX_COMPONENTS];
+
+  BablSampling  *current_sampling = (BablSampling *) babl_sampling (1, 1);
+  BablType      *current_type     = (BablType *) babl_type_id (BABL_DOUBLE);
+  char          *name             = NULL;
+  void          *arg              = first_arg;
 
   va_start (varg, first_arg);
-  
+
   while (1)
     {
       if (BABL_IS_BABL (arg))
         {
-          Babl *babl = (Babl*)arg;
+          Babl *babl = (Babl *) arg;
 
           switch (babl->class_type)
             {
               case BABL_TYPE:
               case BABL_TYPE_FLOAT:
               case BABL_TYPE_INTEGER:
-                current_type = (BablType*) babl;
+                current_type = (BablType *) babl;
                 break;
+
               case BABL_COMPONENT:
                 if (!model)
                   {
                     babl_fatal ("no model specified before component %s",
                                 babl->instance.name);
                   }
-                component [components] = (BablComponent*) babl;
+                component [components] = (BablComponent *) babl;
                 type      [components] = current_type;
                 sampling  [components] = current_sampling;
                 components++;
 
-                if (components>=BABL_MAX_COMPONENTS)
+                if (components >= BABL_MAX_COMPONENTS)
                   {
                     babl_fatal ("maximum number of components (%i) exceeded for %s",
                                 BABL_MAX_COMPONENTS, name);
                   }
                 break;
+
               case BABL_SAMPLING:
-                  current_sampling = (BablSampling*)arg;
-                  break;
+                current_sampling = (BablSampling *) arg;
+                break;
+
               case BABL_MODEL:
-                  if (model)
-                    {
+                if (model)
+                  {
                     babl_log ("args=(%s): model %s already requested",
-                      babl->instance.name, model->instance.name);
-                    }
-                  model = (BablModel*)arg;
-                  break;
+                              babl->instance.name, model->instance.name);
+                  }
+                model = (BablModel *) arg;
+                break;
+
               case BABL_INSTANCE:
               case BABL_FORMAT:
               case BABL_CONVERSION:
@@ -251,8 +255,9 @@ babl_format_new (void *first_arg,
               case BABL_IMAGE:
               case BABL_EXTENSION:
                 babl_log ("%s unexpected",
-                           babl_class_name (babl->class_type));
+                          babl_class_name (babl->class_type));
                 break;
+
               case BABL_SKY: /* shut up compiler */
                 break;
             }
@@ -267,17 +272,17 @@ babl_format_new (void *first_arg,
         {
           name = va_arg (varg, char *);
         }
-      
+
       else if (!strcmp (arg, "packed"))
         {
           planar = 0;
         }
-      
+
       else if (!strcmp (arg, "planar"))
         {
           planar = 1;
         }
-      
+
       else
         {
           babl_fatal ("unhandled argument '%s' for format '%s'", arg, name);
@@ -287,18 +292,18 @@ babl_format_new (void *first_arg,
       if (!arg)
         break;
     }
-    
-  va_end   (varg);
 
-  babl = format_new (name?name:create_name (model, components, component, type),
+  va_end (varg);
+
+  babl = format_new (name ? name : create_name (model, components, component, type),
                      id,
                      planar, components, model,
                      component, sampling, type);
-  { 
+
+  {
     Babl *ret = babl_db_insert (db, babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     return ret;
   }
 }
@@ -315,32 +320,32 @@ babl_format_with_model_as_type (Babl *model,
                                 Babl *type)
 {
   BablComponent *component[10];
-  int i;
+  int            i;
 
-  for (i=0;i<model->model.components;i++)
+  for (i = 0; i < model->model.components; i++)
     {
-      component[i]= model->model.component[i];
+      component[i] = model->model.component[i];
     }
-  component[i]=NULL;
+  component[i] = NULL;
 
   return babl_format_new (
-      model,
-      type,
-      component[0],
-      component[1],
-      component[2],
-      component[3],
-      component[4],
-      component[5],
-      component[6],
-      component[7],
-      component[8],
-      component[9],
-      NULL
-   );
+           model,
+           type,
+           component[0],
+           component[1],
+           component[2],
+           component[3],
+           component[4],
+           component[5],
+           component[6],
+           component[7],
+           component[8],
+           component[9],
+           NULL
+  );
 }
 
-#define test_pixels  256
+#define test_pixels    256
 
 static double *
 test_create (void)
@@ -349,11 +354,11 @@ test_create (void)
   int     i;
 
   srandom (20050728);
-  
+
   test = babl_malloc (sizeof (double) * test_pixels * 4);
 
   for (i = 0; i < test_pixels * 4; i++)
-     test [i] = (double) random () / RAND_MAX;
+    test [i] = (double) random () / RAND_MAX;
 
   return test;
 }
@@ -368,44 +373,44 @@ babl_format_loss (Babl *babl)
   void   *destination;
   double *transformed;
 
-  Babl *ref_fmt;
-  Babl *fmt;
-  Babl *fish_to;
-  Babl *fish_from;
+  Babl   *ref_fmt;
+  Babl   *fmt;
+  Babl   *fish_to;
+  Babl   *fish_from;
 
-  ref_fmt   = babl_format_new (
-       babl_model ("RGBA"),
-       babl_type ("double"),
-       babl_component ("R"),
-       babl_component ("G"),
-       babl_component ("B"),
-       babl_component ("A"),
-       NULL);
+  ref_fmt = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("double"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
 
   if (babl->format.loss != -1.0)
     return babl->format.loss;
-  
-  fmt       = babl; 
+
+  fmt       = babl;
   fish_to   = babl_fish_reference (ref_fmt, fmt);
   fish_from = babl_fish_reference (fmt, ref_fmt);
-  test        = test_create (); 
+
+  test        = test_create ();
   original    = babl_calloc (test_pixels, fmt->format.bytes_per_pixel);
   clipped     = babl_calloc (test_pixels, ref_fmt->format.bytes_per_pixel);
   destination = babl_calloc (test_pixels, fmt->format.bytes_per_pixel);
-  transformed = babl_calloc (test_pixels,  ref_fmt->format.bytes_per_pixel);
+  transformed = babl_calloc (test_pixels, ref_fmt->format.bytes_per_pixel);
 
-  babl_process (fish_to,   test,        original,    test_pixels);
-  babl_process (fish_from, original,    clipped,     test_pixels);
-  babl_process (fish_to,   clipped,     destination, test_pixels);
+  babl_process (fish_to, test, original, test_pixels);
+  babl_process (fish_from, original, clipped, test_pixels);
+  babl_process (fish_to, clipped, destination, test_pixels);
   babl_process (fish_from, destination, transformed, test_pixels);
 
-  loss = babl_rel_avg_error (clipped, test, test_pixels*4);
-  
-  fish_to->fish.processings-=2;
-  fish_from->fish.processings-=2;
-  fish_to->fish.pixels-=test_pixels*2;
-  fish_from->fish.pixels -= test_pixels*2;
+  loss = babl_rel_avg_error (clipped, test, test_pixels * 4);
+
+  fish_to->fish.processings   -= 2;
+  fish_from->fish.processings -= 2;
+  fish_to->fish.pixels        -= test_pixels * 2;
+  fish_from->fish.pixels      -= test_pixels * 2;
 
   babl_free (original);
   babl_free (clipped);
index 0b202ba45098833a1b41cd6dea1cd858b49d8453..8e515aab11d20fd14979e844290164b573ae4b6f 100644 (file)
@@ -57,21 +57,21 @@ image_new (BablFormat     *format,
   babl->image.model      = model;
   babl->image.components = components;
 
-  memcpy (babl->image.component, component, components * sizeof(void*));
-  memcpy (babl->image.type,      type,      components * sizeof(void*));
-  memcpy (babl->image.data,      data,      components * sizeof(void*));
-  memcpy (babl->image.pitch,     pitch,     components * sizeof(int));
-  memcpy (babl->image.stride,    stride,    components * sizeof(int));
+  memcpy (babl->image.component, component, components * sizeof (void *));
+  memcpy (babl->image.type, type, components * sizeof (void *));
+  memcpy (babl->image.data, data, components * sizeof (void *));
+  memcpy (babl->image.pitch, pitch, components * sizeof (int));
+  memcpy (babl->image.stride, stride, components * sizeof (int));
 
   return babl;
 }
 
 Babl *
-babl_image_from_linear (char  *buffer,
-                        Babl  *format)
+babl_image_from_linear (char *buffer,
+                        Babl *format)
 {
   Babl          *babl;
-  BablModel     *model = NULL;
+  BablModel     *model      = NULL;
   int            components = 0;
   int            i;
   BablComponent *component [BABL_MAX_COMPONENTS];
@@ -81,62 +81,64 @@ babl_image_from_linear (char  *buffer,
   int            pitch     [BABL_MAX_COMPONENTS];
   int            stride    [BABL_MAX_COMPONENTS];
 
-  int            offset=0;
-  int            calc_pitch=0;
+  int            offset     = 0;
+  int            calc_pitch = 0;
 
   babl_assert (format);
   babl_assert (format->class_type == BABL_FORMAT ||
                format->class_type == BABL_MODEL);
+
   switch (format->class_type)
     {
       case BABL_FORMAT:
-        model = (BablModel*) format->format.model;
+        model      = (BablModel *) format->format.model;
         components = format->format.components;
 
-        memcpy(component, format->format.component, sizeof (Babl*) * components);
-        memcpy(sampling,  format->format.sampling,  sizeof (Babl*) * components);
-        memcpy(type    ,  format->format.type,      sizeof (Babl*) * components);
+        memcpy (component, format->format.component, sizeof (Babl *) * components);
+        memcpy (sampling, format->format.sampling, sizeof (Babl *) * components);
+        memcpy (type, format->format.type, sizeof (Babl *) * components);
 
-        for (i=0; i < components; i++)
+        for (i = 0; i < components; i++)
           {
             calc_pitch += (type[i]->bits / 8);
           }
-        for (i=0; i < components; i++)
+        for (i = 0; i < components; i++)
           {
-            pitch[i]   = calc_pitch;
-            stride[i]  = 0;
-            data[i]    = buffer + offset;
-            offset       += (type[i]->bits / 8);
+            pitch[i]  = calc_pitch;
+            stride[i] = 0;
+            data[i]   = buffer + offset;
+            offset   += (type[i]->bits / 8);
           }
         break;
+
       case BABL_MODEL:
-        model = (BablModel*) format;
+        model      = (BablModel *) format;
         components = format->format.components;
-        for (i=0; i < components; i++)
+        for (i = 0; i < components; i++)
           {
             calc_pitch += (64 / 8);   /*< known to be double when we create from model */
           }
-        memcpy(component, model->component, sizeof (Babl*) * components);
-        for (i=0; i < components; i++)
+        memcpy (component, model->component, sizeof (Babl *) * components);
+        for (i = 0; i < components; i++)
           {
-            sampling[i]  = (BablSampling*)babl_sampling (1,1);
-            type[i]      = (BablType*)babl_type_id (BABL_DOUBLE);
-            pitch[i]     = calc_pitch;
-            stride[i]    = 0;
-            data[i]      = buffer + offset;
-            offset         += (type[i]->bits / 8);
+            sampling[i] = (BablSampling *) babl_sampling (1, 1);
+            type[i]     = (BablType *) babl_type_id (BABL_DOUBLE);
+            pitch[i]    = calc_pitch;
+            stride[i]   = 0;
+            data[i]     = buffer + offset;
+            offset     += (type[i]->bits / 8);
           }
         break;
+
       default:
         babl_log ("Eeeek!");
         break;
     }
 
   babl = image_new (
-         (BablFormat*)format,
-        model, components,
-        component, sampling, type, data, pitch, stride);
+    (BablFormat *) format,
+    model, components,
+    component, sampling, type, data, pitch, stride);
   return babl;
 }
 
@@ -146,9 +148,9 @@ babl_image (void *first,
 {
   va_list        varg;
   Babl          *babl;
-  int            components= 0;
-  BablFormat    *format    = NULL;
-  BablModel     *model     = NULL;
+  int            components = 0;
+  BablFormat    *format     = NULL;
+  BablModel     *model      = NULL;
   BablComponent *component [BABL_MAX_COMPONENTS];
   BablSampling  *sampling  [BABL_MAX_COMPONENTS];
   BablType      *type      [BABL_MAX_COMPONENTS];
@@ -156,7 +158,7 @@ babl_image (void *first,
   int            pitch     [BABL_MAX_COMPONENTS];
   int            stride    [BABL_MAX_COMPONENTS];
 
-  const char      *arg = first;
+  const char    *arg = first;
 
   va_start (varg, first);
 
@@ -168,41 +170,41 @@ babl_image (void *first,
 
       if (BABL_IS_BABL (arg))
         {
-          Babl *babl = (Babl*)arg;
+          Babl *babl = (Babl *) arg;
 
           if (babl->class_type == BABL_COMPONENT)
             {
-              new_component = (BablComponent *)babl;
+              new_component = (BablComponent *) babl;
             }
           else
             {
-                babl_log ("%s unexpected", babl_class_name (babl->class_type));
-                return NULL;
+              babl_log ("%s unexpected", babl_class_name (babl->class_type));
+              return NULL;
             }
         }
       else
         {
-          new_component = (BablComponent*) babl_component (arg);
+          new_component = (BablComponent *) babl_component (arg);
         }
 
       /* FIXME: add error checking */
       component [components] = new_component;
       sampling  [components] = NULL;
       type      [components] = NULL;
-      data      [components] = va_arg (varg, void*);
+      data      [components] = va_arg (varg, void *);
       pitch     [components] = va_arg (varg, int);
       stride    [components] = va_arg (varg, int);
       components++;
-                
-      if (components>=BABL_MAX_COMPONENTS)
+
+      if (components >= BABL_MAX_COMPONENTS)
         {
           babl_log ("maximum number of components (%i) exceeded", BABL_MAX_COMPONENTS);
         }
 
       arg = va_arg (varg, char *);
     }
-    
-  va_end   (varg);
+
+  va_end (varg);
 
 
   babl = image_new (format, model, components, component, sampling, type, data, pitch, stride);
index 9b660852a691c7f56aab32d36d0baa5f954f957d..bbee0bec4fab6591012e9147838f81a7847964de 100644 (file)
 #include "babl-internal.h"
 
 static const char *class_names[] =
-  {
-    "BablInstance",
-    "BablType",
-    "BablTypeInteger",
-    "BablTypeFloat",
-    "BablSampling",
-    "BablComponent",
-    "BablModel",
-    "BablFormat",
-    "BablConversion",
-    "BablConversionLinear",
-    "BablConversionPlane",
-    "BablConversionPlanar",
-    "BablFish",
-    "BablFishReference",
-    "BablFishSimple",
-    "BablFishPath",
-    "BablImage",
-    "BablExtenstion",
-    "BablSky"
-  };
+{
+  "BablInstance",
+  "BablType",
+  "BablTypeInteger",
+  "BablTypeFloat",
+  "BablSampling",
+  "BablComponent",
+  "BablModel",
+  "BablFormat",
+  "BablConversion",
+  "BablConversionLinear",
+  "BablConversionPlane",
+  "BablConversionPlanar",
+  "BablFish",
+  "BablFishReference",
+  "BablFishSimple",
+  "BablFishPath",
+  "BablImage",
+  "BablExtenstion",
+  "BablSky"
+};
 
 const char *
 babl_class_name (BablClassType klass)
 {
-  return class_names[klass-BABL_INSTANCE];
+  return class_names[klass - BABL_INSTANCE];
 }
 
 /* global variable, indicating whether name lookups
@@ -63,8 +63,8 @@ babl_backtrack (void)
 {
   char buf[512];
 
-  sprintf (buf,"echo bt>/tmp/babl.gdb;"
-               "gdb -q --batch -x /tmp/babl.gdb --pid=%i 2>/dev/null", getpid());
+  sprintf (buf, "echo bt>/tmp/babl.gdb;"
+           "gdb -q --batch -x /tmp/babl.gdb --pid=%i 2>/dev/null", getpid ());
   system (buf);
 }
 
@@ -87,7 +87,7 @@ babl_process (Babl *babl,
   babl_assert (source);
   babl_assert (destination);
   babl_assert (BABL_IS_BABL (babl));
-  babl_assert (n>0);
+  babl_assert (n > 0);
 
   /* matches all conversion classes */
   if (babl->class_type >= BABL_CONVERSION &&
@@ -99,18 +99,18 @@ babl_process (Babl *babl,
       babl->class_type == BABL_FISH_PATH ||
       babl->class_type == BABL_FISH_SIMPLE)
     {
-       long ret;
-       long ticks = babl_ticks ();
-       ret = babl_fish_process (babl, source, destination, n);
-
-       ticks -= babl_ticks();
-       ticks *= -1L;
-
-       babl_total_usecs += ticks;
-       babl->fish.usecs += ticks;
-       babl->fish.processings++;
-       babl->fish.pixels += ret;
-       return ret;
+      long ret;
+      long ticks = babl_ticks ();
+      ret = babl_fish_process (babl, source, destination, n);
+
+      ticks -= babl_ticks ();
+      ticks *= -1L;
+
+      babl_total_usecs += ticks;
+      babl->fish.usecs += ticks;
+      babl->fish.processings++;
+      babl->fish.pixels += ret;
+      return ret;
     }
 
   babl_fatal ("eek");
index 67379dec272cd4ba191f41c3c353e3ee65fa30d6..b145cf75bee124b577b6d1075171944ca37eb73a 100644 (file)
 
 #ifdef BABL_LOG
 
-static void sampling_introspect     (Babl *babl);
-static void model_introspect        (Babl *babl);
-static void type_introspect         (Babl *babl);
-static void format_introspect       (Babl *babl);
+static void sampling_introspect (Babl *babl);
+static void model_introspect (Babl *babl);
+static void type_introspect (Babl *babl);
+static void format_introspect (Babl *babl);
 
-static int  each_introspect         (Babl *babl,
-                                     void *user_data);
+static int  each_introspect (Babl *babl,
+                             void *user_data);
 #endif
 
 void
@@ -37,41 +37,41 @@ babl_introspect (Babl *babl)
 {
 #ifdef BABL_LOG
   Babl *extender_backup = babl_extender ();
-  
-  babl_set_extender (babl_extension_quiet_log());
+
+  babl_set_extender (babl_extension_quiet_log ());
 
   if (babl)
     {
       each_introspect (babl, NULL);
       return;
     }
-  babl_log ("Introspection report");  
-  babl_log ("====================================================");  
+  babl_log ("Introspection report");
+  babl_log ("====================================================");
 
   babl_log ("");
   babl_log ("Data Types:");
-  babl_type_each         (each_introspect, NULL);
+  babl_type_each (each_introspect, NULL);
   babl_log ("");
   babl_log ("Sampling (chroma subsampling) factors:");
-  babl_sampling_each     (each_introspect, NULL);
+  babl_sampling_each (each_introspect, NULL);
   babl_log ("");
   babl_log ("Components:");
-  babl_component_each    (each_introspect, NULL);
+  babl_component_each (each_introspect, NULL);
   babl_log ("");
   babl_log ("Models (of components):");
-  babl_model_each        (each_introspect, NULL);
+  babl_model_each (each_introspect, NULL);
   babl_log ("");
   babl_log ("Pixel formats:");
   babl_format_each (each_introspect, NULL);
   babl_log ("");
   babl_log ("conversions:");
-  babl_conversion_each   (each_introspect, NULL);
+  babl_conversion_each (each_introspect, NULL);
   babl_log ("");
   babl_log ("extensions:");
-  babl_extension_each    (each_introspect, NULL);
+  babl_extension_each (each_introspect, NULL);
   babl_log ("");
   babl_log ("fishes");
-  babl_fish_each         (each_introspect, NULL);
+  babl_fish_each (each_introspect, NULL);
   babl_log ("");
 
   babl_set_extender (extender_backup);
@@ -82,10 +82,10 @@ babl_introspect (Babl *babl)
 static int list_length (void **list)
 {
   void **ptr;
-  int    len=0;
-  
+  int    len = 0;
+
   ptr = list;
-  while (NULL!=*ptr)
+  while (NULL != *ptr)
     {
       ptr++;
       len++;
@@ -101,28 +101,28 @@ item_conversions_introspect (Babl *babl)
 
   if (babl->type.from)
     babl_log ("\t\tconversions from %s: %i",
-       babl->instance.name, list_length ((void **)(babl->type.from)));
+              babl->instance.name, list_length ((void **) (babl->type.from)));
 
-  ptr = (void **)babl->type.from;
+  ptr = (void **) babl->type.from;
 
-  while (ptr && NULL!=*ptr)
+  while (ptr && NULL != *ptr)
     {
-      babl_log ("\t\t\t'%s'", ((Babl *)(*ptr))->instance.name);
+      babl_log ("\t\t\t'%s'", ((Babl *) (*ptr))->instance.name);
       ptr++;
     }
-  
 }
 
 static void
 model_introspect (Babl *babl)
 {
   int i;
+
   babl_log ("\t\tcomponents=%i", babl->model.components);
 
-  for (i=0; i< babl->model.components; i++)
+  for (i = 0; i < babl->model.components; i++)
     {
       babl_log ("\t\tindex[%i] = \"%s\"", i,
-         BABL(babl->model.component[i])->instance.name  );
+                BABL (babl->model.component[i])->instance.name);
     }
 }
 
@@ -147,16 +147,17 @@ static void
 format_introspect (Babl *babl)
 {
   int i;
+
   babl_log ("\t\tmodel=\"%s\"", babl->format.model->instance.name);
   babl_log ("\t\tplanar=%i", babl->format.planar);
-  babl_log ("\t\tcomponents=%i",  babl->format.components);
+  babl_log ("\t\tcomponents=%i", babl->format.components);
 
-  for (i=0; i< babl->format.components; i++)
+  for (i = 0; i < babl->format.components; i++)
     {
       babl_log ("\t\tband[%i] type=\"%s\" sampling=\"%s\" component=\"%s\"",
-                i,   babl->format.type[i]->instance.name,
-                     babl->format.sampling[i]->instance.name,
-                     babl->format.component[i]->instance.name);
+                i, babl->format.type[i]->instance.name,
+                babl->format.sampling[i]->instance.name,
+                babl->format.component[i]->instance.name);
     }
 }
 
@@ -165,7 +166,7 @@ conversion_introspect (Babl *babl)
 {
   babl_log ("\t\tprocessings:%i pixels:%li",
             babl->conversion.processings, babl->conversion.pixels);
-  if (BABL(babl->conversion.source)->class_type == BABL_FORMAT)
+  if (BABL (babl->conversion.source)->class_type == BABL_FORMAT)
     {
       babl_log ("\t\terror: %f", babl_conversion_error (&babl->conversion));
     }
@@ -183,40 +184,47 @@ each_introspect (Babl *babl,
                  void *user_data)
 {
   babl_log ("\t\"%s\"\t%i\t%s",
-   babl->instance.name,
-   babl->instance.id,
-   babl_class_name (babl->class_type));
+            babl->instance.name,
+            babl->instance.id,
+            babl_class_name (babl->class_type));
   switch (babl->class_type)
     {
       case BABL_TYPE:
         type_introspect (babl);
         item_conversions_introspect (babl);
         break;
+
       case BABL_COMPONENT:
         break;
+
       case BABL_MODEL:
         model_introspect (babl);
         item_conversions_introspect (babl);
         break;
+
       case BABL_FORMAT:
         format_introspect (babl);
         item_conversions_introspect (babl);
         break;
+
       case BABL_SAMPLING:
         sampling_introspect (babl);
         item_conversions_introspect (babl);
         break;
+
       case BABL_CONVERSION:
       case BABL_CONVERSION_PLANE:
       case BABL_CONVERSION_PLANAR:
       case BABL_CONVERSION_LINEAR:
         conversion_introspect (babl);
         break;
+
       case BABL_FISH:
       case BABL_FISH_REFERENCE:
       case BABL_FISH_SIMPLE:
         fish_introspect (babl);
         break;
+
       default:
         break;
     }
index 0e71ff499f946b374d9fd5df714c03bb085671bd..24a4f41e8c2687a6b6efcf28bcd25874ce367de4 100644 (file)
 #include <string.h>
 #include "babl-internal.h"
 
-static void *(* malloc_f) (size_t size) = malloc;
-static void  (* free_f)   (void *ptr)   = free;
+static void *(*malloc_f)(size_t size) = malloc;
+static void  (*free_f)(void *ptr)     = free;
 
 static void *first_malloc_used = NULL;
 static void *first_free_used   = NULL;
 
 void
-babl_set_malloc (void *(* malloc_function) (size_t size))
+babl_set_malloc (void *(*malloc_function)(size_t size))
 {
   malloc_f = malloc_function;
 }
 
 void
-babl_set_free   (void (* free_function) (void *ptr))
+babl_set_free (void (*free_function)(void *ptr))
 {
   free_f = free_function;
 }
@@ -44,14 +44,14 @@ static char *signature = "So long and thanks for all the fish.";
 
 typedef struct
 {
-  char   *signature;
-  size_t  size;
+  char  *signature;
+  size_t size;
 } BablAllocInfo;
 
-#define OFFSET   (sizeof(BablAllocInfo))
+#define OFFSET    (sizeof (BablAllocInfo))
 
-#define BAI(ptr)    ((BablAllocInfo*)(((char*)ptr)-OFFSET))
-#define IS_BAI(ptr) (BAI(ptr)->signature == signature)
+#define BAI(ptr)       ((BablAllocInfo *) (((char *) ptr) - OFFSET))
+#define IS_BAI(ptr)    (BAI (ptr)->signature == signature)
 
 /* runtime statistics: */
 static int mallocs  = 0;
@@ -65,8 +65,9 @@ static const char *
 mem_stats (void)
 {
   static char buf[128];
+
   sprintf (buf, "mallocs:%i callocs:%i strdups:%i dups:%i allocs:%i frees:%i reallocs:%i\t|",
-    mallocs, callocs, strdups, dups, mallocs+callocs+strdups+dups, frees, reallocs);
+           mallocs, callocs, strdups, dups, mallocs + callocs + strdups + dups, frees, reallocs);
   return buf;
 }
 
@@ -74,7 +75,7 @@ static void
 functions_sanity (void)
 {
   if (first_malloc_used != malloc_f ||
-      first_free_used   != free_f)
+      first_free_used != free_f)
     {
       if (first_malloc_used == NULL)
         {
@@ -87,8 +88,8 @@ functions_sanity (void)
         }
     }
 }
-  
-/* Allocate /size/ bytes of memory 
+
+/* Allocate /size/ bytes of memory
  *
  * contents of memory undefined.
  */
@@ -102,12 +103,12 @@ babl_malloc (size_t size)
   functions_sanity ();
   ret = malloc_f (size + OFFSET);
   if (!ret)
-    babl_fatal ("args=(%i): failed",  size);
+    babl_fatal ("args=(%i): failed", size);
 
-  BAI(ret + OFFSET)->signature = signature;
-  BAI(ret + OFFSET)->size      = size;
+  BAI (ret + OFFSET)->signature = signature;
+  BAI (ret + OFFSET)->size      = size;
   mallocs++;
-  return (void*)(ret + OFFSET);
+  return (void *) (ret + OFFSET);
 }
 
 /* Create a duplicate allocation of the same size, note
@@ -118,11 +119,11 @@ void *
 babl_dup (void *ptr)
 {
   void *ret;
+
   babl_assert (IS_BAI (ptr));
 
-  ret = babl_malloc (BAI(ptr)->size);
-  memcpy (ret, ptr, BAI(ptr)->size);
+  ret = babl_malloc (BAI (ptr)->size);
+  memcpy (ret, ptr, BAI (ptr)->size);
 
   dups++;
   mallocs--;
@@ -141,11 +142,11 @@ babl_free (void *ptr,
 {
   if (!ptr)
     return;
-  if(!IS_BAI(ptr))
+  if (!IS_BAI (ptr))
     babl_fatal ("memory not allocated by babl allocator");
   functions_sanity ();
-  BAI(ptr)->signature=NULL;
-  free_f (BAI(ptr));
+  BAI (ptr)->signature = NULL;
+  free_f (BAI (ptr));
   frees++;
 }
 
@@ -153,8 +154,8 @@ babl_free (void *ptr,
  * common allocated memory between old and new size is preserved.
  */
 void *
-babl_realloc (void   *ptr,
-              size_t  size)
+babl_realloc (void  *ptr,
+              size_t size)
 {
   void *ret = NULL;
 
@@ -165,7 +166,7 @@ babl_realloc (void   *ptr,
 
   babl_assert (IS_BAI (ptr));
 
-  if (size==0)
+  if (size == 0)
     {
       babl_free (ptr);
       return NULL;
@@ -192,8 +193,8 @@ babl_realloc (void   *ptr,
     }
 
   if (!ret)
-    babl_fatal ("args=(%p, %i): failed",  ptr, size);
-  
+    babl_fatal ("args=(%p, %i): failed", ptr, size);
+
   return NULL;
 }
 
@@ -202,12 +203,12 @@ void *
 babl_calloc (size_t nmemb,
              size_t size)
 {
-  void *ret = babl_malloc (nmemb*size);
+  void *ret = babl_malloc (nmemb * size);
 
   if (!ret)
-    babl_fatal ("args=(%i, %i): failed",  nmemb, size);
+    babl_fatal ("args=(%i, %i): failed", nmemb, size);
 
-  memset (ret, 0, nmemb*size);
+  memset (ret, 0, nmemb * size);
 
   callocs++;
   mallocs--;
@@ -220,7 +221,7 @@ size_t
 babl_sizeof (void *ptr)
 {
   babl_assert (IS_BAI (ptr));
-  return BAI(ptr)->size;
+  return BAI (ptr)->size;
 }
 
 /*  duplicate allocation needed for a string, and
@@ -231,10 +232,10 @@ babl_strdup (const char *s)
 {
   char *ret;
 
-  ret = babl_malloc (strlen (s)+1);
+  ret = babl_malloc (strlen (s) + 1);
   if (!ret)
-    babl_log ("args=(%s): failed",  s);
-  strcpy (ret, s); 
+    babl_log ("args=(%s): failed", s);
+  strcpy (ret, s);
 
   strdups++;
   mallocs--;
@@ -252,26 +253,26 @@ babl_strcat (char       *dest,
              const char *src)
 {
   char *ret;
-  int src_len;
-  int dst_len;
+  int   src_len;
+  int   dst_len;
 
   src_len = strlen (src);
   if (!dest)
     {
-      ret = babl_malloc (src_len+1);
+      ret = babl_malloc (src_len + 1);
       strcpy (ret, src);
       return ret;
     }
   babl_assert (IS_BAI (dest));
   dst_len = strlen (dest);
-  
+
   ret = dest;
 
   if (babl_sizeof (dest) < src_len + dst_len + 1)
     {
       size_t new_size = babl_sizeof (dest);
       while (new_size < src_len + dst_len + 1)
-        new_size*=2;
+        new_size *= 2;
       ret = babl_realloc (dest, new_size);
     }
 
@@ -288,9 +289,9 @@ babl_memory_sanity (void)
   if (frees != mallocs + strdups + callocs)
     {
       babl_log ("memory usage does not add up!\n"
-"%s\n"
-"\tbalance: %i-%i=%i\n",
-  mem_stats(), (strdups+mallocs+callocs),frees, (strdups+mallocs+callocs)-frees);
+                "%s\n"
+                "\tbalance: %i-%i=%i\n",
+                mem_stats (), (strdups + mallocs + callocs), frees, (strdups + mallocs + callocs) - frees);
       return -1;
     }
   return 0;
index 2956aca265480aa00770f4d794d3de85ef88d705..122c7983db9266f34a3f8989255185c8234d022e 100644 (file)
 #include "babl-db.h"
 
 
-static int 
+static int
 each_babl_model_destroy (Babl *babl,
-                         void         *data)
+                         void *data)
 {
   babl_free (babl->model.from);
   babl_free (babl);
   return 0;  /* continue iterating */
 }
 
-static char buf[512]="";
+static char buf[512] = "";
 
 static const char *
 create_name (const char     *name,
@@ -41,12 +41,13 @@ create_name (const char     *name,
              BablComponent **component)
 {
   char *p = buf;
+
   if (name)
     return name;
   while (components--)
     {
       sprintf (p, (*component)->instance.name);
-      p+=strlen ((*component)->instance.name);
+      p += strlen ((*component)->instance.name);
       component++;
     }
   return buf;
@@ -60,19 +61,19 @@ model_new (const char     *name,
 {
   Babl *babl;
 
-  babl                   = babl_malloc (sizeof (BablModel) +
-                                        sizeof (BablComponent*) * (components) +
-                                        strlen (name) + 1);
-  babl->model.component = (void*)(((char*)babl) + sizeof (BablModel));
-  babl->instance.name   = (void*)(((char*)babl->model.component) + sizeof (BablComponent*) * (components));
-  
+  babl = babl_malloc (sizeof (BablModel) +
+                      sizeof (BablComponent *) * (components) +
+                      strlen (name) + 1);
+  babl->model.component = (void *) (((char *) babl) + sizeof (BablModel));
+  babl->instance.name   = (void *) (((char *) babl->model.component) + sizeof (BablComponent *) * (components));
+
   babl->class_type       = BABL_MODEL;
   babl->instance.id      = id;
   babl->model.components = components;
   strcpy (babl->instance.name, name);
-  memcpy (babl->model.component, component, sizeof (BablComponent*)*components);
+  memcpy (babl->model.component, component, sizeof (BablComponent *) * components);
 
-  babl->model.from         = NULL;
+  babl->model.from = NULL;
   return babl;
 }
 
@@ -82,37 +83,37 @@ babl_model_new (void *first_argument,
 {
   va_list        varg;
   Babl          *babl;
-  int            id          = 0;
-  int            components  = 0;
-  const char    *arg         = first_argument;
-  const char    *name        = NULL;
+  int            id         = 0;
+  int            components = 0;
+  const char    *arg        = first_argument;
+  const char    *name       = NULL;
   BablComponent *component [BABL_MAX_COMPONENTS];
 
   va_start (varg, first_argument);
-  
+
   while (1)
     {
-
-
       if (BABL_IS_BABL (arg))
         {
-          Babl *babl = (Babl*)arg;
+          Babl *babl = (Babl *) arg;
 
           switch (babl->class_type)
             {
               case BABL_COMPONENT:
-                component [components] = (BablComponent*) babl;
+                component [components] = (BablComponent *) babl;
                 components++;
 
-                if (components>=BABL_MAX_COMPONENTS)
+                if (components >= BABL_MAX_COMPONENTS)
                   {
                     babl_log ("maximum number of components (%i) exceeded for %s",
-                      BABL_MAX_COMPONENTS, name);
+                              BABL_MAX_COMPONENTS, name);
                   }
                 break;
+
               case BABL_MODEL:
-                  babl_log ("submodels not handled yet");
-                  break;
+                babl_log ("submodels not handled yet");
+                break;
+
               case BABL_TYPE:
               case BABL_TYPE_INTEGER:
               case BABL_TYPE_FLOAT:
@@ -133,6 +134,7 @@ babl_model_new (void *first_argument,
               case BABL_EXTENSION:
                 babl_log ("%s unexpected", babl_class_name (babl->class_type));
                 break;
+
               case BABL_SKY: /* shut up compiler */
                 break;
             }
@@ -147,7 +149,7 @@ babl_model_new (void *first_argument,
         {
           name = va_arg (varg, char *);
         }
-      
+
       else
         {
           babl_fatal ("unhandled argument '%s' for babl_model '%s'", arg, name);
@@ -157,21 +159,21 @@ babl_model_new (void *first_argument,
       if (!arg)
         break;
     }
-    
-  va_end   (varg);
+
+  va_end (varg);
 
   babl = model_new (create_name (name, components, component), id, components, component);
-  
-  { 
+
+  {
     Babl *ret = babl_db_insert (db, babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     return ret;
   }
 }
 
 
-#define TOLERANCE 0.001
+#define TOLERANCE      0.001
 
 #define test_pixels    512
 
@@ -180,13 +182,13 @@ test_create (void)
 {
   double *test;
   int     i;
-  
+
   srandom (20050728);
 
   test = babl_malloc (sizeof (double) * test_pixels * 4);
 
   for (i = 0; i < test_pixels * 4; i++)
-     test [i] = ((double) random () / RAND_MAX ) * 1.4 - 0.2;
+    test [i] = ((double) random () / RAND_MAX) * 1.4 - 0.2;
 
   return test;
 }
@@ -194,50 +196,50 @@ test_create (void)
 static Babl *reference_format (void)
 {
   static Babl *self = NULL;
-  
+
   if (!self)
-     self = babl_format_new (
-       babl_model ("RGBA"),
-       babl_type ("double"),
-       babl_component ("R"),
-       babl_component ("G"),
-       babl_component ("B"),
-       babl_component ("A"),
-       NULL);
+    self = babl_format_new (
+      babl_model ("RGBA"),
+      babl_type ("double"),
+      babl_component ("R"),
+      babl_component ("G"),
+      babl_component ("B"),
+      babl_component ("A"),
+      NULL);
   return self;
 }
 
 static Babl *construct_double_format (Babl *model)
 {
-  void *argument[42+1];
+  void *argument[42 + 1];
   int   args = 0;
   int   i;
 
   argument[args++] = model;
   argument[args++] = babl_type ("double");
 
-  for (i=0;i<model->model.components; i++)
+  for (i = 0; i < model->model.components; i++)
     {
       argument[args++] = model->model.component[i];
     }
   argument[args++] = NULL;
 
-#define o(argno) argument[argno],
-  return babl_format_new (o(0)  o(1)  o(2)  o(3)
-                          o(4)  o(5)  o(6)  o(7)
-                          o(8)  o(9) o(10) o(11)
-                         o(12) o(13) o(14) o(15)
-                         o(16) o(17) o(18) o(19) 
-                         o(20) o(21) o(22) o(23) 
-                         o(24) o(25) o(26) o(27)
-                         o(28) o(29) o(30) o(31)
-                         o(32) o(33) o(34) o(35)
-                         o(36) o(37) o(38) o(39) 
-                         o(40) o(41) o(42) NULL);
+#define o(argno)    argument[argno],
+  return babl_format_new (o (0)  o (1)  o (2)  o (3)
+                          o (4)  o (5)  o (6)  o (7)
+                          o (8)  o (9) o (10) o (11)
+                          o (12) o (13) o (14) o (15)
+                          o (16) o (17) o (18) o (19)
+                          o (20) o (21) o (22) o (23)
+                          o (24) o (25) o (26) o (27)
+                          o (28) o (29) o (30) o (31)
+                          o (32) o (33) o (34) o (35)
+                          o (36) o (37) o (38) o (39)
+                          o (40) o (41) o (42) NULL);
 #undef o
 }
 
-double 
+double
 babl_model_is_symmetric (Babl *babl)
 {
   double *test;
@@ -245,68 +247,68 @@ babl_model_is_symmetric (Babl *babl)
   double *clipped;
   void   *destination;
   double *transformed;
-  int     symmetric=1;
+  int     symmetric = 1;
 
-  Babl *ref_fmt;
-  Babl *fmt;
-  Babl *fish_to;
-  Babl *fish_from;
+  Babl   *ref_fmt;
+  Babl   *fmt;
+  Babl   *fish_to;
+  Babl   *fish_from;
 
   test      = test_create ();
   ref_fmt   = reference_format ();
   fmt       = construct_double_format (babl);
   fish_to   = babl_fish_reference (ref_fmt, fmt);
   fish_from = babl_fish_reference (fmt, ref_fmt);
-  
-  original    = babl_calloc (1,64/8 * babl->model.components * test_pixels);
-  clipped     = babl_calloc (1,64/8 * 4 * test_pixels);
-  destination = babl_calloc (1,64/8 * babl->model.components * test_pixels);
-  transformed = babl_calloc (1,64/8 * 4 * test_pixels);
-
-  babl_process (fish_to,   test,        original,    test_pixels);
-  babl_process (fish_from, original,    clipped,     test_pixels);
-  babl_process (fish_to,   clipped,     destination, test_pixels);
+
+  original    = babl_calloc (1, 64 / 8 * babl->model.components * test_pixels);
+  clipped     = babl_calloc (1, 64 / 8 * 4 * test_pixels);
+  destination = babl_calloc (1, 64 / 8 * babl->model.components * test_pixels);
+  transformed = babl_calloc (1, 64 / 8 * 4 * test_pixels);
+
+  babl_process (fish_to, test, original, test_pixels);
+  babl_process (fish_from, original, clipped, test_pixels);
+  babl_process (fish_to, clipped, destination, test_pixels);
   babl_process (fish_from, destination, transformed, test_pixels);
 
-  fish_to->fish.processings-=2;
-  fish_from->fish.processings-=2;
-  fish_to->fish.pixels-=test_pixels*2;
-  fish_from->fish.pixels -= test_pixels*2;
+  fish_to->fish.processings   -= 2;
+  fish_from->fish.processings -= 2;
+  fish_to->fish.pixels        -= test_pixels * 2;
+  fish_from->fish.pixels      -= test_pixels * 2;
 
   {
     int i;
-    int log=0;
+    int log = 0;
 
-    for (i=0;i<test_pixels;i++)
+    for (i = 0; i < test_pixels; i++)
       {
         int j;
-        for (j=0;j<4;j++)
-           if (fabs (clipped[i*4+j] - transformed[i*4+j])>TOLERANCE)
-             {
-                if (!log)
-                  log=1;
-                symmetric=0;
-             }
+        for (j = 0; j < 4; j++)
+          if (fabs (clipped[i *4 + j] - transformed[i * 4 + j]) > TOLERANCE)
+            {
+              if (!log)
+                log = 1;
+              symmetric = 0;
+            }
         if (log && log < 5)
           {
             babl_log ("%s", babl->instance.name);
-            babl_log ("\ttest:     %2.3f %2.3f %2.3f %2.3f", test [i*4+0],
-                                                             test [i*4+1],
-                                                             test [i*4+2],
-                                                             test [i*4+3]);
-            babl_log ("\tclipped:  %2.3f %2.3f %2.3f %2.3f", clipped [i*4+0],
-                                                             clipped [i*4+1],
-                                                             clipped [i*4+2],
-                                                             clipped [i*4+3]);
-            babl_log ("\ttrnsfrmd: %2.3f %2.3f %2.3f %2.3f", transformed [i*4+0],
-                                                             transformed [i*4+1],
-                                                             transformed [i*4+2],
-                                                             transformed [i*4+3]);
+            babl_log ("\ttest:     %2.3f %2.3f %2.3f %2.3f", test [i *4 + 0],
+                      test [i * 4 + 1],
+                      test [i * 4 + 2],
+                      test [i * 4 + 3]);
+            babl_log ("\tclipped:  %2.3f %2.3f %2.3f %2.3f", clipped [i *4 + 0],
+                      clipped [i * 4 + 1],
+                      clipped [i * 4 + 2],
+                      clipped [i * 4 + 3]);
+            babl_log ("\ttrnsfrmd: %2.3f %2.3f %2.3f %2.3f", transformed [i *4 + 0],
+                      transformed [i * 4 + 1],
+                      transformed [i * 4 + 2],
+                      transformed [i * 4 + 3]);
             log++;
           }
       }
   }
-  
+
   babl_free (original);
   babl_free (clipped);
   babl_free (destination);
index 125da99e50ebc176a763610dddfda515a206adb9..85804e44d00b4ddddfa656975d1d2a9126709ed9 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#define HORIZONTAL_MIN 1
-#define HORIZONTAL_MAX 4
-#define VERTICAL_MIN   1
-#define VERTICAL_MAX   4
+#define HORIZONTAL_MIN    1
+#define HORIZONTAL_MAX    4
+#define VERTICAL_MIN      1
+#define VERTICAL_MAX      4
 
 #include "babl-internal.h"
 
-static BablSampling sampling_db[(HORIZONTAL_MAX-HORIZONTAL_MIN+1)*
-                                (VERTICAL_MAX-VERTICAL_MIN+1)];
+static BablSampling sampling_db[(HORIZONTAL_MAX - HORIZONTAL_MIN + 1) *
+                                (VERTICAL_MAX - VERTICAL_MIN + 1)];
 
 Babl *
 babl_sampling (int horizontal,
                int vertical)
 {
-  if (vertical>=1 &&
-      vertical<=4 &&
-      horizontal>=1 &&
-      horizontal<=4)
-    return (Babl*)&sampling_db [ (vertical-1) * 4 + (horizontal-1)];
+  if (vertical >= 1 &&
+      vertical <= 4 &&
+      horizontal >= 1 &&
+      horizontal <= 4)
+    return (Babl *) &sampling_db [ (vertical - 1) * 4 + (horizontal - 1)];
   else
     babl_log ("babl_samping(%i,%i): arguments out of bounds",
               horizontal, vertical);
@@ -43,7 +43,7 @@ babl_sampling (int horizontal,
 }
 
 
-static int 
+static int
 each_babl_sampling_destroy (Babl *babl,
                             void *data)
 {
@@ -52,18 +52,18 @@ each_babl_sampling_destroy (Babl *babl,
 }
 
 void
-babl_sampling_each (BablEachFunction  each_fun,
-                    void             *user_data)
+babl_sampling_each (BablEachFunction each_fun,
+                    void            *user_data)
 {
   int horizontal;
   int vertical;
 
-  for (horizontal=HORIZONTAL_MIN; horizontal<=HORIZONTAL_MAX; horizontal++)
-    for (vertical=VERTICAL_MIN; vertical<=VERTICAL_MAX; vertical++)
+  for (horizontal = HORIZONTAL_MIN; horizontal <= HORIZONTAL_MAX; horizontal++)
+    for (vertical = VERTICAL_MIN; vertical <= VERTICAL_MAX; vertical++)
       {
-       int index= (vertical-VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN);
-       if (each_fun (BABL (&sampling_db[index]), user_data))
-         return;
+        int index = (vertical - VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN);
+        if (each_fun (BABL (&sampling_db[index]), user_data))
+          return;
       }
 }
 
@@ -80,18 +80,18 @@ babl_sampling_init (void)
   int horizontal;
   int vertical;
 
-  for (horizontal=HORIZONTAL_MIN; horizontal<=HORIZONTAL_MAX; horizontal++)
-    for (vertical=VERTICAL_MIN; vertical<=VERTICAL_MAX; vertical++)
+  for (horizontal = HORIZONTAL_MIN; horizontal <= HORIZONTAL_MAX; horizontal++)
+    for (vertical = VERTICAL_MIN; vertical <= VERTICAL_MAX; vertical++)
       {
-        int index= (vertical-VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN);
+        int index = (vertical - VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN);
         sampling_db[index].instance.class_type = BABL_SAMPLING;
-        sampling_db[index].instance.id = 0;
-        sampling_db[index].horizontal = horizontal;
-        sampling_db[index].vertical   = vertical;
-        sampling_db[index].instance.name = sampling_db[index].name;
-        sampling_db[index].name[0]='0'+horizontal;
-        sampling_db[index].name[1]=':';
-        sampling_db[index].name[2]='0'+vertical;
-        sampling_db[index].name[3]='\0';
+        sampling_db[index].instance.id         = 0;
+        sampling_db[index].horizontal          = horizontal;
+        sampling_db[index].vertical            = vertical;
+        sampling_db[index].instance.name       = sampling_db[index].name;
+        sampling_db[index].name[0]             = '0' + horizontal;
+        sampling_db[index].name[1]             = ':';
+        sampling_db[index].name[2]             = '0' + vertical;
+        sampling_db[index].name[3]             = '\0';
       }
 }
index b0e7b612f31b90655d792e3d5f4a2e998a7e731f..194eeab0d5c2bce76ecefeb4433d0c2142ab1d0c 100644 (file)
@@ -20,7 +20,7 @@
 #include "babl-internal.h"
 
 static int OK;
+
 static int
 foo (Babl *babl,
      void *user_data)
@@ -38,16 +38,16 @@ type_sanity (Babl *babl,
   /* ensure that every type has reference conversions to
    * and from double */
   void **ptr;
-  int  ok;
+  int    ok;
 
   ok = 0;
   if (babl->type.from)
     {
       ptr = (void **) babl->type.from;
 
-      while (ptr && NULL!=*ptr)
+      while (ptr && NULL != *ptr)
         {
-          if (babl_conversion_destination ((Babl *)(*ptr)) == babl_type_id (BABL_DOUBLE))
+          if (babl_conversion_destination ((Babl *) (*ptr)) == babl_type_id (BABL_DOUBLE))
             {
               ok = 1;
               break;
@@ -73,16 +73,16 @@ model_sanity (Babl *babl,
   /* ensure that every type has reference conversions to
    * and from rgba */
   void **ptr;
-  int  ok;
+  int    ok;
 
   ok = 0;
   if (babl->model.from)
     {
       ptr = (void **) babl->model.from;
 
-      while (ptr && NULL!=*ptr)
+      while (ptr && NULL != *ptr)
         {
-          if (babl_conversion_destination ((Babl *)(*ptr)) == babl_model_id (BABL_RGBA))
+          if (babl_conversion_destination ((Babl *) (*ptr)) == babl_model_id (BABL_RGBA))
             {
               ok = 1;
               break;
@@ -92,7 +92,7 @@ model_sanity (Babl *babl,
     }
   if (!ok)
     {
-      OK=0;
+      OK = 0;
       babl_log ("lack of sanity! model '%s' has no conversion to 'rgba'",
                 babl->instance.name);
     }
@@ -106,11 +106,11 @@ id_sanity (Babl *babl,
 {
   if (0 && 0 == babl->instance.id &&
       babl->instance.creator &&
-      !strcmp(BABL(babl->instance.creator)->instance.name, "BablBase"))
+      !strcmp (BABL (babl->instance.creator)->instance.name, "BablBase"))
     {
-      OK=0;
+      OK = 0;
       babl_log ("%s\t'%s' has id==0",
-        babl_class_name (babl->class_type), babl->instance.name);
+                babl_class_name (babl->class_type), babl->instance.name);
     }
   return 0;
 }
index 5a81296f86228fdff5d61f8859130abd4075fb32..a65f52a550a60d140a0d95d087b54acf375a028e 100644 (file)
@@ -25,7 +25,7 @@
 #include "babl-db.h"
 
 
-static int 
+static int
 each_babl_type_destroy (Babl *babl,
                         void *data)
 {
@@ -36,22 +36,22 @@ each_babl_type_destroy (Babl *babl,
 
 
 static Babl *
-type_new (const char  *name,
-          int          id,
-          int          bits)
+type_new (const char *name,
+          int         id,
+          int         bits)
 {
   Babl *babl;
 
   babl_assert (bits != 0);
   babl_assert (bits % 8 == 0);
-  
+
   babl                = babl_malloc (sizeof (BablType) + strlen (name) + 1);
-  babl->instance.name = (void*)((char*) babl + sizeof (BablType));
+  babl->instance.name = (void *) ((char *) babl + sizeof (BablType));
   babl->class_type    = BABL_TYPE;
   babl->instance.id   = id;
   strcpy (babl->instance.name, name);
-  babl->type.bits     = bits;
-  babl->type.from     = NULL;
+  babl->type.bits = bits;
+  babl->type.from = NULL;
 
   return babl;
 }
@@ -60,30 +60,30 @@ Babl *
 babl_type_new (void *first_arg,
                ...)
 {
-  va_list  varg;
-  Babl    *babl;
-  int      id         = 0;
-  int      is_integer = 0;
-  int      bits       = 0;
-  long     min        = 0;
-  long     max        = 255;
-  double   min_val    = 0.0;
-  double   max_val    = 0.0;
-
-  const char *arg=first_arg;
+  va_list     varg;
+  Babl       *babl;
+  int         id         = 0;
+  int         is_integer = 0;
+  int         bits       = 0;
+  long        min        = 0;
+  long        max        = 255;
+  double      min_val    = 0.0;
+  double      max_val    = 0.0;
+
+  const char *arg = first_arg;
 
   va_start (varg, first_arg);
-  
+
   while (1)
     {
       arg = va_arg (varg, char *);
       if (!arg)
         break;
-     
+
       if (BABL_IS_BABL (arg))
         {
 #ifdef BABL_LOG
-          Babl *babl = (Babl*)arg;
+          Babl *babl = (Babl *) arg;
 
           babl_log ("%s unexpected", babl_class_name (babl->class_type));
 #endif
@@ -93,12 +93,12 @@ babl_type_new (void *first_arg,
         {
           id = va_arg (varg, int);
         }
-      
+
       else if (!strcmp (arg, "bits"))
         {
           bits = va_arg (varg, int);
-          min = 0;
-          max = 1<<bits;
+          min  = 0;
+          max  = 1 << bits;
         }
       else if (!strcmp (arg, "integer"))
         {
@@ -120,48 +120,50 @@ babl_type_new (void *first_arg,
         {
           max_val = va_arg (varg, double);
         }
-      
+
       else
         {
           babl_fatal ("unhandled argument '%s' for format '%s'", arg, first_arg);
         }
     }
-    
-  va_end   (varg);
+
+  va_end (varg);
 
   babl = type_new (first_arg, id, bits);
 
-  { 
+  {
     Babl *ret = babl_db_insert (db, babl);
-    if (ret!=babl)
-        babl_free (babl);
+    if (ret != babl)
+      babl_free (babl);
     return ret;
   }
 }
 
 
-#define TOLERANCE 0.000000001
-#define samples   512
+#define TOLERANCE    0.000000001
+#define samples      512
 
 double test[samples];
 
 static double r_interval (double min, double max)
 {
   long int rand_i = random ();
-  double ret;
-  ret = (double) rand_i / RAND_MAX;
-  ret*=(max-min);
-  ret+=min;
+  double   ret;
+
+  ret  = (double) rand_i / RAND_MAX;
+  ret *= (max - min);
+  ret += min;
   return ret;
 }
 
 static void test_init (double min, double max)
 {
   int i;
+
   srandom (20050728);
-  for (i=0;i<samples;i++)
+  for (i = 0; i < samples; i++)
     {
-      test [i]=r_interval(min,max);
+      test [i] = r_interval (min, max);
     }
 }
 
@@ -169,71 +171,71 @@ static void test_init (double min, double max)
 static Babl *double_vector_format (void)
 {
   static Babl *self = NULL;
-  
+
   if (!self)
-     self = babl_format_new (
-       babl_model ("Y"),
-       babl_type ("double"),
-       babl_component ("Y"),
-       NULL);
+    self = babl_format_new (
+      babl_model ("Y"),
+      babl_type ("double"),
+      babl_component ("Y"),
+      NULL);
   return self;
 }
 
 int
 babl_type_is_symmetric (Babl *babl)
 {
-  int     is_symmetrical=1;
+  int     is_symmetrical = 1;
   void   *original;
   double *clipped;
   void   *destination;
   double *transformed;
 
-  Babl *ref_fmt;
-  Babl *fmt;
-  Babl *fish_to;
-  Babl *fish_from;
+  Babl   *ref_fmt;
+  Babl   *fmt;
+  Babl   *fish_to;
+  Babl   *fish_from;
 
   test_init (0.0, 182.0);
-  
+
   ref_fmt = double_vector_format ();
-  fmt = babl_format_new (babl_model ("Y"),
-                         babl,
-                         babl_component ("Y"),
-                         NULL);
+  fmt     = babl_format_new (babl_model ("Y"),
+                             babl,
+                             babl_component ("Y"),
+                             NULL);
   fish_to   = babl_fish_reference (ref_fmt, fmt);
   fish_from = babl_fish_reference (fmt, ref_fmt);
-  
-  original    = babl_calloc (1,babl->type.bits/8 * samples);
-  clipped     = babl_calloc (1,64/8              * samples);
-  destination = babl_calloc (1,babl->type.bits/8 * samples);
-  transformed = babl_calloc (1,64/8              * samples);
-  
-  babl_process (fish_to,   test,        original,    samples);
-  babl_process (fish_from, original,    clipped,     samples);
-  babl_process (fish_to,   clipped,     destination, samples);
+
+  original    = babl_calloc (1, babl->type.bits / 8 * samples);
+  clipped     = babl_calloc (1, 64 / 8 * samples);
+  destination = babl_calloc (1, babl->type.bits / 8 * samples);
+  transformed = babl_calloc (1, 64 / 8 * samples);
+
+  babl_process (fish_to, test, original, samples);
+  babl_process (fish_from, original, clipped, samples);
+  babl_process (fish_to, clipped, destination, samples);
   babl_process (fish_from, destination, transformed, samples);
 
-  fish_from->fish.processings-=2;
-  fish_to->fish.processings-=2;
-  fish_from->fish.pixels -= samples*2;
-  fish_to->fish.pixels -= samples*2;
+  fish_from->fish.processings -= 2;
+  fish_to->fish.processings   -= 2;
+  fish_from->fish.pixels      -= samples * 2;
+  fish_to->fish.pixels        -= samples * 2;
 
   {
-    int cnt=0;
+    int cnt = 0;
     int i;
-    for (i=0;i<samples;i++)
+    for (i = 0; i < samples; i++)
       {
-        if (fabs (clipped[i] - transformed[i])> TOLERANCE)
+        if (fabs (clipped[i] - transformed[i]) > TOLERANCE)
           {
-            if (cnt++<4)
-            babl_log ("%s:  %f %f %f)",
-             babl->instance.name, test[i], clipped[i], transformed[i]
-             );
-            is_symmetrical=0;
+            if (cnt++ < 4)
+              babl_log ("%s:  %f %f %f)",
+                        babl->instance.name, test[i], clipped[i], transformed[i]
+              );
+            is_symmetrical = 0;
           }
       }
   }
-  
+
   babl_free (original);
   babl_free (clipped);
   babl_free (destination);
index 8ba72782efa34ad8eb06bc700668d1af9046e1e0..4adb6965ac000afc0827c439180c8d2e63e15f39 100644 (file)
 static int list_length (void **list)
 {
   void **ptr;
-  int    len=0;
+  int    len = 0;
 
   ptr = list;
-  while (NULL!=*ptr)
+  while (NULL != *ptr)
     {
       ptr++;
       len++;
@@ -42,37 +42,38 @@ void
 babl_add_ptr_to_list (void ***list,
                       void   *new)
 {
-  int orig_len=0;
+  int orig_len = 0;
 
   if (*list)
     {
       orig_len = list_length (*list);
     }
 
-  *list = babl_realloc ( (*list),
-                          sizeof(void *) * (orig_len + 2));
+  *list = babl_realloc ((*list),
+                        sizeof (void *) * (orig_len + 2));
 
   if (!(*list))
     {
-       babl_fatal ("failed to realloc");
+      babl_fatal ("failed to realloc");
     }
 
-  (*list)[orig_len]=new;
-  (*list)[orig_len+1]=NULL;
+  (*list)[orig_len]     = new;
+  (*list)[orig_len + 1] = NULL;
 }
 
 void
-babl_list_each (void             **list,
-                BablEachFunction   each_fun,
-                void              *user_data)
+babl_list_each (void           **list,
+                BablEachFunction each_fun,
+                void            *user_data)
 {
   int i;
+
   if (!list)
     return;
-  for (i=0; i < list_length (list); i++)
+  for (i = 0; i < list_length (list); i++)
     {
-      if (each_fun ((Babl*) list[i], user_data))
-         break;
+      if (each_fun ((Babl *) list[i], user_data))
+        break;
     }
 }
 
@@ -82,15 +83,16 @@ babl_list_each (void             **list,
 static struct timeval start_time;
 static struct timeval measure_time;
 
-#define usecs(time) ((time.tv_sec-start_time.tv_sec)*1000000 + time.tv_usec)
+#define usecs(time)    ((time.tv_sec - start_time.tv_sec) * 1000000 + time.tv_usec)
 
 static void
 init_ticks (void)
 {
-  static int done=0;
+  static int done = 0;
+
   if (done)
     return;
-  done=1;
+  done = 1;
   gettimeofday (&start_time, NULL);
 }
 
@@ -99,7 +101,7 @@ babl_ticks (void)
 {
   init_ticks ();
   gettimeofday (&measure_time, NULL);
-  return usecs(measure_time) - usecs(start_time);
+  return usecs (measure_time) - usecs (start_time);
 }
 
 double
@@ -110,8 +112,8 @@ babl_rel_avg_error (double *imgA,
   double error = 0.0;
   long   i;
 
-  for (i=0; i<samples; i++)
-      error += fabs (imgA[i] - imgB[i]);
+  for (i = 0; i < samples; i++)
+    error += fabs (imgA[i] - imgB[i]);
 
   if (error >= 0.000001)
     error /= samples;
index f6d2783eede149f3321042ff0e1e7e7c60d53290..ddb8508951dfb1a7675a5252d4756e35bca58895 100644 (file)
 
 #include "babl-internal.h"
 
-static int ref_count=0;
+static int ref_count = 0;
 
 void
 babl_init (void)
 {
-  if (ref_count++==0)
+  if (ref_count++ == 0)
     {
       babl_internal_init ();
       babl_type_init ();
@@ -41,27 +41,26 @@ babl_init (void)
       babl_sanity ();
       babl_fish_init ();
       babl_sanity ();
-
     }
 }
 
 void
 babl_destroy (void)
 {
-  if (!--ref_count)
+  if (!-- ref_count)
     {
       if (getenv ("BABL_STATS"))
-      {
-         char logfile_name[]="/tmp/babl-stats.html";
-         FILE *logfile;
-         logfile = fopen (logfile_name, "w");
-         if (logfile)
-           {
-            babl_fish_stats (logfile);
-            fclose (logfile);
-           }
-      }
-      
+        {
+          char  logfile_name[] = "/tmp/babl-stats.html";
+          FILE *logfile;
+          logfile = fopen (logfile_name, "w");
+          if (logfile)
+            {
+              babl_fish_stats (logfile);
+              fclose (logfile);
+            }
+        }
+
       babl_extension_destroy ();
       babl_fish_destroy ();
       babl_conversion_destroy ();
index f33909111213f0d4e0e3f8d269b380141f7f58ff..6e9825756b00a5fd2802b1d701412a8c4284e71d 100644 (file)
 
 extern int babl_hmpf_on_name_lookups;
 
-static void types  (void);
+static void types (void);
 static void models (void);
 
 void
 babl_base_init (void)
 {
-  babl_hmpf_on_name_lookups ++;
+  babl_hmpf_on_name_lookups++;
 
   types ();
   models ();
   babl_formats_init ();
 
-  babl_hmpf_on_name_lookups --;
+  babl_hmpf_on_name_lookups--;
 }
 
 void
@@ -50,10 +50,10 @@ babl_base_destroy (void)
 static void
 types (void)
 {
-  babl_base_type_float  ();
-  babl_base_type_u8     ();
-  babl_base_type_u16    ();
-  babl_base_type_u32    ();
+  babl_base_type_float ();
+  babl_base_type_u8 ();
+  babl_base_type_u16 ();
+  babl_base_type_u32 ();
 }
 
 /*
@@ -64,7 +64,7 @@ types (void)
 static void
 models (void)
 {
-  babl_base_model_rgb   ();
-  babl_base_model_gray  ();
+  babl_base_model_rgb ();
+  babl_base_model_gray ();
   babl_base_model_ycbcr ();
 }
index 61233c4541fc5824e354837a22ed18922243c39c..ca4238cac265f5126c7fd2015dde070d516d4cc8 100644 (file)
@@ -25,315 +25,315 @@ void
 babl_formats_init (void)
 {
   babl_format_new (
-      babl_model_id (BABL_RGBA_GAMMA_2_2),
-      babl_type_id (BABL_DOUBLE),
-      babl_component_id (BABL_RED_GAMMA_2_2),
-      babl_component_id (BABL_GREEN_GAMMA_2_2),
-      babl_component_id (BABL_BLUE_GAMMA_2_2),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_GAMMA_2_2),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_RED_GAMMA_2_2),
-      babl_component_id (BABL_GREEN_GAMMA_2_2),
-      babl_component_id (BABL_BLUE_GAMMA_2_2),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_GAMMA_2_2),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_RED_GAMMA_2_2),
-      babl_component_id (BABL_GREEN_GAMMA_2_2),
-      babl_component_id (BABL_BLUE_GAMMA_2_2),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_GAMMA_2_2),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_RED_GAMMA_2_2),
-      babl_component_id (BABL_GREEN_GAMMA_2_2),
-      babl_component_id (BABL_BLUE_GAMMA_2_2),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGB_GAMMA_2_2),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_RED_GAMMA_2_2),
-      babl_component_id (BABL_GREEN_GAMMA_2_2),
-      babl_component_id (BABL_BLUE_GAMMA_2_2),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGB_GAMMA_2_2),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_RED_GAMMA_2_2),
-      babl_component_id (BABL_GREEN_GAMMA_2_2),
-      babl_component_id (BABL_BLUE_GAMMA_2_2),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGB_GAMMA_2_2),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_RED_GAMMA_2_2),
-      babl_component_id (BABL_GREEN_GAMMA_2_2),
-      babl_component_id (BABL_BLUE_GAMMA_2_2),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMA_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_LUMA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_LUMA_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_LUMA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_LUMA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_LUMA_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_GAMMA_2_2),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_LUMA),
-      NULL);
-  babl_format_new (
-      "name", "Y'CbCr u8",
-      babl_model_id (BABL_YCBCR),
-      babl_type_id (BABL_U8_LUMA),
-      babl_component_id (BABL_LUMA),
-      babl_type_id (BABL_U8_CHROMA),
-      babl_component_id (BABL_CB),
-      babl_component_id (BABL_CR),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_YCBCR),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_CB),
-      babl_component_id (BABL_CR),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_YCBCR_ALPHA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_CB),
-      babl_component_id (BABL_CR),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_RED),
-      babl_component_id (BABL_GREEN),
-      babl_component_id (BABL_BLUE),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_RED),
-      babl_component_id (BABL_GREEN),
-      babl_component_id (BABL_BLUE),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA),
-      babl_type_id (BABL_DOUBLE),
-      babl_component_id (BABL_RED),
-      babl_component_id (BABL_GREEN),
-      babl_component_id (BABL_BLUE),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_RED),
-      babl_component_id (BABL_GREEN),
-      babl_component_id (BABL_BLUE),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_PREMULTIPLIED),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_RED_MUL_ALPHA),
-      babl_component_id (BABL_GREEN_MUL_ALPHA),
-      babl_component_id (BABL_BLUE_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_PREMULTIPLIED),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_RED_MUL_ALPHA),
-      babl_component_id (BABL_GREEN_MUL_ALPHA),
-      babl_component_id (BABL_BLUE_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGBA_PREMULTIPLIED),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_RED_MUL_ALPHA),
-      babl_component_id (BABL_GREEN_MUL_ALPHA),
-      babl_component_id (BABL_BLUE_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGB),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_RED),
-      babl_component_id (BABL_GREEN),
-      babl_component_id (BABL_BLUE),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGB),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_RED),
-      babl_component_id (BABL_GREEN),
-      babl_component_id (BABL_BLUE),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_RGB),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_RED),
-      babl_component_id (BABL_GREEN),
-      babl_component_id (BABL_BLUE),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_ALPHA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMINANCE),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMINANCE_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMINANCE),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_ALPHA),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_LUMINANCE),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_LUMINANCE_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY),
-      babl_type_id (BABL_U16),
-      babl_component_id (BABL_LUMINANCE),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_ALPHA),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_LUMINANCE),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_LUMINANCE_MUL_ALPHA),
-      babl_component_id (BABL_ALPHA),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_GRAY),
-      babl_type_id (BABL_U8),
-      babl_component_id (BABL_LUMINANCE),
-      NULL);
+    babl_model_id (BABL_RGBA_GAMMA_2_2),
+    babl_type_id (BABL_DOUBLE),
+    babl_component_id (BABL_RED_GAMMA_2_2),
+    babl_component_id (BABL_GREEN_GAMMA_2_2),
+    babl_component_id (BABL_BLUE_GAMMA_2_2),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_GAMMA_2_2),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_RED_GAMMA_2_2),
+    babl_component_id (BABL_GREEN_GAMMA_2_2),
+    babl_component_id (BABL_BLUE_GAMMA_2_2),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_GAMMA_2_2),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_RED_GAMMA_2_2),
+    babl_component_id (BABL_GREEN_GAMMA_2_2),
+    babl_component_id (BABL_BLUE_GAMMA_2_2),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_GAMMA_2_2),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_RED_GAMMA_2_2),
+    babl_component_id (BABL_GREEN_GAMMA_2_2),
+    babl_component_id (BABL_BLUE_GAMMA_2_2),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGB_GAMMA_2_2),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_RED_GAMMA_2_2),
+    babl_component_id (BABL_GREEN_GAMMA_2_2),
+    babl_component_id (BABL_BLUE_GAMMA_2_2),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGB_GAMMA_2_2),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_RED_GAMMA_2_2),
+    babl_component_id (BABL_GREEN_GAMMA_2_2),
+    babl_component_id (BABL_BLUE_GAMMA_2_2),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGB_GAMMA_2_2),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_RED_GAMMA_2_2),
+    babl_component_id (BABL_GREEN_GAMMA_2_2),
+    babl_component_id (BABL_BLUE_GAMMA_2_2),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMA_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_LUMA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_LUMA_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_LUMA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_LUMA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_LUMA_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_GAMMA_2_2),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_LUMA),
+    NULL);
+  babl_format_new (
+    "name", "Y'CbCr u8",
+    babl_model_id (BABL_YCBCR),
+    babl_type_id (BABL_U8_LUMA),
+    babl_component_id (BABL_LUMA),
+    babl_type_id (BABL_U8_CHROMA),
+    babl_component_id (BABL_CB),
+    babl_component_id (BABL_CR),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_YCBCR),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_CB),
+    babl_component_id (BABL_CR),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_YCBCR_ALPHA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_CB),
+    babl_component_id (BABL_CR),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
+    babl_component_id (BABL_BLUE),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
+    babl_component_id (BABL_BLUE),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA),
+    babl_type_id (BABL_DOUBLE),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
+    babl_component_id (BABL_BLUE),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
+    babl_component_id (BABL_BLUE),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_PREMULTIPLIED),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_RED_MUL_ALPHA),
+    babl_component_id (BABL_GREEN_MUL_ALPHA),
+    babl_component_id (BABL_BLUE_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_PREMULTIPLIED),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_RED_MUL_ALPHA),
+    babl_component_id (BABL_GREEN_MUL_ALPHA),
+    babl_component_id (BABL_BLUE_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGBA_PREMULTIPLIED),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_RED_MUL_ALPHA),
+    babl_component_id (BABL_GREEN_MUL_ALPHA),
+    babl_component_id (BABL_BLUE_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGB),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
+    babl_component_id (BABL_BLUE),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGB),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
+    babl_component_id (BABL_BLUE),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_RGB),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
+    babl_component_id (BABL_BLUE),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_ALPHA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMINANCE),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMINANCE_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMINANCE),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_ALPHA),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_LUMINANCE),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_LUMINANCE_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY),
+    babl_type_id (BABL_U16),
+    babl_component_id (BABL_LUMINANCE),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_ALPHA),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_LUMINANCE),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_LUMINANCE_MUL_ALPHA),
+    babl_component_id (BABL_ALPHA),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_GRAY),
+    babl_type_id (BABL_U8),
+    babl_component_id (BABL_LUMINANCE),
+    NULL);
 
   /* overriding name, since the generated name would be wrong due
    * to differing types
    */
   babl_format_new (
-      "name", "Y'CbCr u8",
-      babl_model_id (BABL_YCBCR),
-      babl_type_id (BABL_U8_LUMA),
-      babl_component_id (BABL_LUMA),
-      babl_type_id (BABL_U8_CHROMA),
-      babl_component_id (BABL_CB),
-      babl_component_id (BABL_CR),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_YCBCR),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_CB),
-      babl_component_id (BABL_CR),
-      NULL);
-  babl_format_new (
-      babl_model_id (BABL_YCBCR_ALPHA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_LUMA),
-      babl_type_id (BABL_FLOAT),
-      babl_component_id (BABL_CB),
-      babl_component_id (BABL_CR),
-      babl_component_id (BABL_ALPHA),
-      NULL);
+    "name", "Y'CbCr u8",
+    babl_model_id (BABL_YCBCR),
+    babl_type_id (BABL_U8_LUMA),
+    babl_component_id (BABL_LUMA),
+    babl_type_id (BABL_U8_CHROMA),
+    babl_component_id (BABL_CB),
+    babl_component_id (BABL_CR),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_YCBCR),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_CB),
+    babl_component_id (BABL_CR),
+    NULL);
+  babl_format_new (
+    babl_model_id (BABL_YCBCR_ALPHA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_LUMA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_CB),
+    babl_component_id (BABL_CR),
+    babl_component_id (BABL_ALPHA),
+    NULL);
 }
index a4fbdc1d158b42b89c739b11292263b7fd307121..d2e2ac9682c155441156c0561da340d9964403ac 100644 (file)
 
 #include "util.h"
 
-static void components    (void);
-static void models        (void);
-static void conversions   (void);
-static void formats       (void);
+static void components (void);
+static void models (void);
+static void conversions (void);
+static void formats (void);
 
 void
 babl_base_model_cmyk (void)
 {
-  components    ();
-  models        ();
-  conversions   ();
-  formats       ();
+  components ();
+  models ();
+  conversions ();
+  formats ();
 }
 
 static void
 components (void)
 {
-    babl_component_new (
-   "cyan",
-   "id", BABL_CYAN,
-   NULL);
+  babl_component_new (
+    "cyan",
+    "id", BABL_CYAN,
+    NULL);
 
   babl_component_new (
-   "yellow",
-   "id", BABL_YELLOW,
-   NULL);
+    "yellow",
+    "id", BABL_YELLOW,
+    NULL);
 
   babl_component_new (
-   "magenta",
-   "id", BABL_MAGENTA,
-   NULL);
+    "magenta",
+    "id", BABL_MAGENTA,
+    NULL);
 
   babl_component_new (
-   "key",
-   "id", BABL_KEY,
-   NULL);
+    "key",
+    "id", BABL_KEY,
+    NULL);
 }
 
 static void
@@ -98,13 +98,13 @@ models (void)
 static long
 rgb_to_cmyk (void *src,
              void *dst,
-             long   n)
+             long  n)
 {
   while (n--)
     {
-      double red   = ((double*)src)[0];
-      double green = ((double*)src)[1];
-      double blue  = ((double*)src)[2];
+      double red   = ((double *) src)[0];
+      double green = ((double *) src)[1];
+      double blue  = ((double *) src)[2];
 
       double cyan, magenta, yellow, key;
 
@@ -115,17 +115,17 @@ rgb_to_cmyk (void *src,
       yellow  = 1.0 - blue;
 
       key = 1.0;
-      if (cyan    < key) key = cyan;
+      if (cyan < key) key = cyan;
       if (magenta < key) key = magenta;
-      if (yellow  < key) key = yellow;
+      if (yellow < key) key = yellow;
 
       key *= pullout;
 
       if (key < 1.0)
         {
-          cyan    = (cyan - key)    / (1.0 -key);
-          magenta = (magenta - key) / (1.0 -key);
-          yellow  = (yellow - key)  / (1.0 -key);
+          cyan    = (cyan - key) / (1.0 - key);
+          magenta = (magenta - key) / (1.0 - key);
+          yellow  = (yellow - key) / (1.0 - key);
         }
       else
         {
@@ -134,36 +134,36 @@ rgb_to_cmyk (void *src,
           yellow  = 0.0;
         }
 
-      ((double*)dst)[0] = cyan;
-      ((double*)dst)[1] = magenta;
-      ((double*)dst)[2] = yellow;
-      ((double*)dst)[3] = key;
+      ((double *) dst)[0] = cyan;
+      ((double *) dst)[1] = magenta;
+      ((double *) dst)[2] = yellow;
+      ((double *) dst)[3] = key;
 
-      src+=4*sizeof(double);
-      dst+=4*sizeof(double)
+      src += 4 * sizeof (double);
+      dst += 4 * sizeof (double)
     }
   return n;
 }
 
-static long 
+static long
 cmyk_to_rgb (void *src,
              void *dst,
              long  n)
 {
   while (n--)
     {
-      double cyan    = ((double*)src)[0];
-      double yellow  = ((double*)src)[1];
-      double magenta = ((double*)src)[2];
-      double key     = ((double*)src)[3];
+      double cyan    = ((double *) src)[0];
+      double yellow  = ((double *) src)[1];
+      double magenta = ((double *) src)[2];
+      double key     = ((double *) src)[3];
 
       double red, green, blue;
 
       if (key < 1.0)
         {
-          cyan    = cyan    * (1.0 - key) + key;
+          cyan    = cyan * (1.0 - key) + key;
           magenta = magenta * (1.0 - key) + key;
-          yellow  = yellow  * (1.0 - key) + key;
+          yellow  = yellow * (1.0 - key) + key;
         }
       else
         {
@@ -174,14 +174,14 @@ cmyk_to_rgb (void *src,
       green = 1.0 - magenta;
       blue  = 1.0 - yellow;
 
-      ((double*)dst)[0] = red;
-      ((double*)dst)[1] = green;
-      ((double*)dst)[2] = blue;
+      ((double *) dst)[0] = red;
+      ((double *) dst)[1] = green;
+      ((double *) dst)[2] = blue;
 
-      ((double*)dst)[3] = 1.0;
+      ((double *) dst)[3] = 1.0;
 
-      src+=4*sizeof(double);
-      dst+=4*sizeof(double)
+      src += 4 * sizeof (double);
+      dst += 4 * sizeof (double)
     }
   return n;
 }
@@ -191,18 +191,18 @@ conversions (void)
 {
   babl_conversion_new (
     "babl-base: rgba to cmyk",
-    "source",      babl_model_id (BABL_RGBA),
+    "source", babl_model_id (BABL_RGBA),
     "destination", babl_model_id (BABL_CMYK),
-    "linear",      rgb_to_cmyk,
+    "linear", rgb_to_cmyk,
     NULL
   );
 
 
   babl_conversion_new (
     "babl-base: cmyk to rgba",
-    "source",      babl_model_id (BABL_CMYK),
+    "source", babl_model_id (BABL_CMYK),
     "destination", babl_model_id (BABL_RGBA),
-    "linear",      cmyk_to_rgb,
+    "linear", cmyk_to_rgb,
     NULL
   );
 }
index 7967a15216e778e3594ed4c7e2247d4c0c498a9f..2981a535cc6876c3c184ece4f772a7506babd9b7 100644 (file)
 #include "math.h"
 #include "babl-base.h"
 
-static void components  (void);
-static void models      (void);
+static void components (void);
+static void models (void);
 static void conversions (void);
 
 void babl_base_model_gray (void)
 {
-  components  ();
-  models      ();
+  components ();
+  models ();
   conversions ();
 }
 
@@ -39,28 +39,28 @@ static void
 components (void)
 {
   babl_component_new (
-   "Y", 
-   "id",    BABL_LUMINANCE,
-   "luma",
-   NULL);
+    "Y",
+    "id", BABL_LUMINANCE,
+    "luma",
+    NULL);
 
   babl_component_new (
-   "Ya",
-   "id",    BABL_LUMINANCE_MUL_ALPHA,
-   "luma",
-   NULL);
+    "Ya",
+    "id", BABL_LUMINANCE_MUL_ALPHA,
+    "luma",
+    NULL);
 
   babl_component_new (
-   "Y'", 
-   "id",    BABL_LUMA,
-   "luma",
-   NULL);
+    "Y'",
+    "id", BABL_LUMA,
+    "luma",
+    NULL);
 
   babl_component_new (
-   "Y'a", 
-   "id",    BABL_LUMA_MUL_ALPHA,
-   "luma",
-   NULL);
+    "Y'a",
+    "id", BABL_LUMA_MUL_ALPHA,
+    "luma",
+    NULL);
 }
 
 static void
@@ -114,17 +114,17 @@ rgba_to_graya (char *src,
       double red, green, blue;
       double luminance, alpha;
 
-      red   = ((double *)src)[0];
-      green = ((double *)src)[1];
-      blue  = ((double *)src)[2];
-      alpha = ((double *)src)[3];
+      red   = ((double *) src)[0];
+      green = ((double *) src)[1];
+      blue  = ((double *) src)[2];
+      alpha = ((double *) src)[3];
 
-      luminance  = red   * RGB_LUMINANCE_RED +
-                   green * RGB_LUMINANCE_GREEN +
-                   blue  * RGB_LUMINANCE_BLUE;
+      luminance = red * RGB_LUMINANCE_RED +
+                  green * RGB_LUMINANCE_GREEN +
+                  blue * RGB_LUMINANCE_BLUE;
 
-      ((double*)dst)[0] = luminance;
-      ((double*)dst)[1] = alpha;
+      ((double *) dst)[0] = luminance;
+      ((double *) dst)[1] = alpha;
 
       src += sizeof (double) * 4;
       dst += sizeof (double) * 2;
@@ -142,16 +142,16 @@ rgba_to_gray (char *src,
       double red, green, blue;
       double luminance, alpha;
 
-      red   = ((double *)src)[0];
-      green = ((double *)src)[1];
-      blue  = ((double *)src)[2];
-      alpha = ((double *)src)[3];
+      red   = ((double *) src)[0];
+      green = ((double *) src)[1];
+      blue  = ((double *) src)[2];
+      alpha = ((double *) src)[3];
 
-      luminance  = red   * RGB_LUMINANCE_RED +
-                   green * RGB_LUMINANCE_GREEN +
-                   blue  * RGB_LUMINANCE_BLUE;
+      luminance = red * RGB_LUMINANCE_RED +
+                  green * RGB_LUMINANCE_GREEN +
+                  blue * RGB_LUMINANCE_BLUE;
 
-      ((double*)dst)[0] = luminance;
+      ((double *) dst)[0] = luminance;
 
       src += sizeof (double) * 4;
       dst += sizeof (double) * 1;
@@ -178,18 +178,18 @@ rgb_to_gray_2_2 (int    src_bands,
       red   = *(double *) src[0];
       green = *(double *) src[1];
       blue  = *(double *) src[2];
-      if (src_bands>3)
-        alpha = *(double *)src[3];
+      if (src_bands > 3)
+        alpha = *(double *) src[3];
       else
         alpha = 1.0;
 
-      luminance  = red   * RGB_LUMINANCE_RED +
-                   green * RGB_LUMINANCE_GREEN +
-                   blue  * RGB_LUMINANCE_BLUE;
-      *(double*)dst[0] = linear_to_gamma_2_2 (luminance);
+      luminance = red * RGB_LUMINANCE_RED +
+                  green * RGB_LUMINANCE_GREEN +
+                  blue * RGB_LUMINANCE_BLUE;
+      *(double *) dst[0] = linear_to_gamma_2_2 (luminance);
 
-      if (dst_bands==2)
-        *(double*)dst[1] = alpha;
+      if (dst_bands == 2)
+        *(double *) dst[1] = alpha;
 
       BABL_PLANAR_STEP
     }
@@ -213,21 +213,21 @@ gray_2_2_to_rgb (int    src_bands,
       double red, green, blue;
       double alpha;
 
-      luminance = gamma_2_2_to_linear (*(double *)src[0]);
+      luminance = gamma_2_2_to_linear (*(double *) src[0]);
       red       = luminance;
       green     = luminance;
       blue      = luminance;
       if (src_bands > 1)
-        alpha = *(double *)src[1];
+        alpha = *(double *) src[1];
       else
-        alpha     = 1.0;
+        alpha = 1.0;
 
-      *(double*)dst[0] = red;
-      *(double*)dst[1] = green;
-      *(double*)dst[2] = blue;
+      *(double *) dst[0] = red;
+      *(double *) dst[1] = green;
+      *(double *) dst[2] = blue;
 
-      if (dst_bands>3)
-        *(double*)dst[3] = alpha;
+      if (dst_bands > 3)
+        *(double *) dst[3] = alpha;
 
       BABL_PLANAR_STEP
     }
@@ -247,19 +247,19 @@ graya_to_rgba (char *src,
       double red, green, blue;
       double alpha;
 
-      luminance = ((double *)src)[0];
-      alpha     = ((double *)src)[1];
+      luminance = ((double *) src)[0];
+      alpha     = ((double *) src)[1];
       red       = luminance;
       green     = luminance;
       blue      = luminance;
 
-      ((double*)dst)[0] = red;
-      ((double*)dst)[1] = green;
-      ((double*)dst)[2] = blue;
-      ((double*)dst)[3] = alpha;
+      ((double *) dst)[0] = red;
+      ((double *) dst)[1] = green;
+      ((double *) dst)[2] = blue;
+      ((double *) dst)[3] = alpha;
 
-      src += sizeof(double)*2;
-      dst += sizeof(double)*4;
+      src += sizeof (double) * 2;
+      dst += sizeof (double) * 4;
     }
   return n;
 }
@@ -275,18 +275,18 @@ gray_to_rgba (char *src,
       double luminance;
       double red, green, blue;
 
-      luminance = ((double *)src)[0];
+      luminance = ((double *) src)[0];
       red       = luminance;
       green     = luminance;
       blue      = luminance;
 
-      ((double*)dst)[0] = red;
-      ((double*)dst)[1] = green;
-      ((double*)dst)[2] = blue;
-      ((double*)dst)[3] = 1.0;
+      ((double *) dst)[0] = red;
+      ((double *) dst)[1] = green;
+      ((double *) dst)[2] = blue;
+      ((double *) dst)[3] = 1.0;
 
-      src += sizeof(double)*1;
-      dst += sizeof(double)*4;
+      src += sizeof (double) * 1;
+      dst += sizeof (double) * 4;
     }
   return n;
 }
@@ -306,8 +306,8 @@ gray_alpha_premultiplied_to_rgba (int    src_bands,
 
   while (n--)
     {
-      double luminance = *(double *)src[0];
-      double alpha     = *(double *)src[1];
+      double luminance = *(double *) src[0];
+      double alpha     = *(double *) src[1];
 
       if (alpha > 0.00001)
         {
@@ -317,11 +317,11 @@ gray_alpha_premultiplied_to_rgba (int    src_bands,
         {
           luminance = 0.0;
         }
-      
-      *(double*)dst[0] = luminance;
-      *(double*)dst[1] = luminance;
-      *(double*)dst[2] = luminance;
-      *(double*)dst[3] = alpha;
+
+      *(double *) dst[0] = luminance;
+      *(double *) dst[1] = luminance;
+      *(double *) dst[2] = luminance;
+      *(double *) dst[3] = alpha;
       BABL_PLANAR_STEP
     }
   return n;
@@ -343,20 +343,20 @@ rgba_to_gray_alpha_premultiplied (int    src_bands,
 
   while (n--)
     {
-      double red       = *(double *)src[0];
-      double green     = *(double *)src[1];
-      double blue      = *(double *)src[2];
-      double alpha     = *(double *)src[3];
+      double red   = *(double *) src[0];
+      double green = *(double *) src[1];
+      double blue  = *(double *) src[2];
+      double alpha = *(double *) src[3];
       double luminance;
 
-      luminance  = red   * RGB_LUMINANCE_RED +
-                   green * RGB_LUMINANCE_GREEN +
-                   blue  * RGB_LUMINANCE_BLUE;
+      luminance = red * RGB_LUMINANCE_RED +
+                  green * RGB_LUMINANCE_GREEN +
+                  blue * RGB_LUMINANCE_BLUE;
 
       luminance *= alpha;
-      
-      *(double*)dst[0] = luminance;
-      *(double*)dst[1] = alpha;
+
+      *(double *) dst[0] = luminance;
+      *(double *) dst[1] = alpha;
       BABL_PLANAR_STEP
     }
   return n;
@@ -376,14 +376,14 @@ non_premultiplied_to_premultiplied (int    src_bands,
   while (n--)
     {
       double alpha;
-      int band;
+      int    band;
 
-      alpha = *(double *)src[src_bands-1];
-      for (band=0; band<src_bands-1;band++)
+      alpha = *(double *) src[src_bands - 1];
+      for (band = 0; band < src_bands - 1; band++)
         {
-          *(double*)dst[band] = *(double*) src[band] * alpha;
+          *(double *) dst[band] = *(double *) src[band] * alpha;
         }
-      *(double*)dst[dst_bands-1] = alpha;
+      *(double *) dst[dst_bands - 1] = alpha;
 
       BABL_PLANAR_STEP
     }
@@ -404,21 +404,21 @@ premultiplied_to_non_premultiplied (int    src_bands,
   while (n--)
     {
       double alpha;
-      int band;
+      int    band;
 
-      alpha = *(double *)src[src_bands-1];
-      for (band=0; band<src_bands-1;band++)
+      alpha = *(double *) src[src_bands - 1];
+      for (band = 0; band < src_bands - 1; band++)
         {
-          if (alpha>0.001)
+          if (alpha > 0.001)
             {
-              *(double*)dst[band] = *(double*) src[band] / alpha;
+              *(double *) dst[band] = *(double *) src[band] / alpha;
             }
           else
             {
-              *(double*)dst[band] = 0.001;
+              *(double *) dst[band] = 0.001;
             }
         }
-      *(double*)dst[dst_bands-1] = alpha;
+      *(double *) dst[dst_bands - 1] = alpha;
 
       BABL_PLANAR_STEP
     }
@@ -432,24 +432,24 @@ rgba2gray_gamma_2_2_premultiplied (char *src,
 {
   while (n--)
     {
-      double red   = ((double*)src)[0];
-      double green = ((double*)src)[1];
-      double blue  = ((double*)src)[2];
-      double alpha = ((double*)src)[3];
+      double red   = ((double *) src)[0];
+      double green = ((double *) src)[1];
+      double blue  = ((double *) src)[2];
+      double alpha = ((double *) src)[3];
 
       double luminance;
       double luma;
-        
-      luminance  = red   * RGB_LUMINANCE_RED +
-                   green * RGB_LUMINANCE_GREEN +
-                   blue  * RGB_LUMINANCE_BLUE;
+
+      luminance = red * RGB_LUMINANCE_RED +
+                  green * RGB_LUMINANCE_GREEN +
+                  blue * RGB_LUMINANCE_BLUE;
       luma = linear_to_gamma_2_2 (luminance);
 
-      ((double*)dst)[0] = luma * alpha;
-      ((double*)dst)[1] = alpha;
+      ((double *) dst)[0] = luma * alpha;
+      ((double *) dst)[1] = alpha;
 
-      src+=4 * sizeof (double);
-      dst+=2 * sizeof (double);
+      src += 4 * sizeof (double);
+      dst += 2 * sizeof (double);
     }
   return n;
 }
@@ -458,24 +458,24 @@ rgba2gray_gamma_2_2_premultiplied (char *src,
 static long
 gray_gamma_2_2_premultiplied2rgba (char *src,
                                    char *dst,
-                                   long   n)
+                                   long  n)
 {
   while (n--)
     {
-      double luma  = ((double*) src)[0];
-      double alpha = ((double*) src)[1];
+      double luma  = ((double *) src)[0];
+      double alpha = ((double *) src)[1];
       double luminance;
 
-      luma = luma / alpha;
+      luma      = luma / alpha;
       luminance = gamma_2_2_to_linear (luma);
-      
-      ((double*)dst)[0] = luminance;
-      ((double*)dst)[1] = luminance;
-      ((double*)dst)[2] = luminance;
-      ((double*)dst)[3] = alpha;
-
-      src+=2 * sizeof (double);
-      dst+=4 * sizeof (double);
+
+      ((double *) dst)[0] = luminance;
+      ((double *) dst)[1] = luminance;
+      ((double *) dst)[2] = luminance;
+      ((double *) dst)[3] = alpha;
+
+      src += 2 * sizeof (double);
+      dst += 4 * sizeof (double);
     }
   return n;
 }
@@ -487,28 +487,28 @@ conversions (void)
   babl_conversion_new (
     babl_model_id (BABL_GRAY_GAMMA_2_2),
     babl_model_id (BABL_RGBA),
-    "planar",      gray_2_2_to_rgb,
+    "planar", gray_2_2_to_rgb,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_GRAY_GAMMA_2_2),
-    "planar",      rgb_to_gray_2_2,
+    "planar", rgb_to_gray_2_2,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA),
     babl_model_id (BABL_RGBA),
-    "planar",      gray_2_2_to_rgb,
+    "planar", gray_2_2_to_rgb,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA),
-    "planar",      rgb_to_gray_2_2,
+    "planar", rgb_to_gray_2_2,
     NULL
   );
 
@@ -516,70 +516,70 @@ conversions (void)
   babl_conversion_new (
     babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
     babl_model_id (BABL_RGBA),
-    "linear",      gray_gamma_2_2_premultiplied2rgba,
+    "linear", gray_gamma_2_2_premultiplied2rgba,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
-    "linear",      rgba2gray_gamma_2_2_premultiplied,
+    "linear", rgba2gray_gamma_2_2_premultiplied,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_GRAY),
     babl_model_id (BABL_RGBA),
-    "linear",      gray_to_rgba,
+    "linear", gray_to_rgba,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_GRAY_ALPHA),
     babl_model_id (BABL_RGBA),
-    "linear",      graya_to_rgba,
+    "linear", graya_to_rgba,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_GRAY_ALPHA),
-    "linear",      rgba_to_graya,
+    "linear", rgba_to_graya,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_GRAY),
-    "linear",      rgba_to_gray,
+    "linear", rgba_to_gray,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_GRAY_ALPHA),
     babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
-    "planar",      non_premultiplied_to_premultiplied,
+    "planar", non_premultiplied_to_premultiplied,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
     babl_model_id (BABL_GRAY_ALPHA),
-    "planar",      premultiplied_to_non_premultiplied,
+    "planar", premultiplied_to_non_premultiplied,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
     babl_model_id (BABL_RGBA),
-    "planar",      gray_alpha_premultiplied_to_rgba,
+    "planar", gray_alpha_premultiplied_to_rgba,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
-    "planar",      rgba_to_gray_alpha_premultiplied,
+    "planar", rgba_to_gray_alpha_premultiplied,
     NULL
   );
 }
index 3a9651dacd78ee642346eea6c907c0a9e99b553c..2d811f31a8fd7668d39a8285bbb19a289ec58cd2 100644 (file)
 #include "util.h"
 #include "babl-base.h"
 
-static void models        (void);
-static void components    (void);
-static void conversions   (void);
-static void formats       (void);
+static void models (void);
+static void components (void);
+static void conversions (void);
+static void formats (void);
 
 void
 babl_base_model_rgb (void)
 {
-  components    ();
-  models        ();
-  conversions   ();
-  formats       ();
+  components ();
+  models ();
+  conversions ();
+  formats ();
 }
 
 static void
 components (void)
 {
-
-
-
   babl_component_new (
     "Ra",
-    "id",    BABL_RED_MUL_ALPHA,
+    "id", BABL_RED_MUL_ALPHA,
     "luma",
     "chroma",
     "alpha",
     NULL);
   babl_component_new (
     "Ga",
-    "id",    BABL_GREEN_MUL_ALPHA,
+    "id", BABL_GREEN_MUL_ALPHA,
     "luma",
     "chroma",
     "alpha",
     NULL);
   babl_component_new (
     "Ba",
-    "id",    BABL_BLUE_MUL_ALPHA,
+    "id", BABL_BLUE_MUL_ALPHA,
     "luma",
     "chroma",
     "alpha",
@@ -67,51 +64,50 @@ components (void)
 
   babl_component_new (
     "R'",
-   "id",    BABL_RED_GAMMA_2_2,
+    "id", BABL_RED_GAMMA_2_2,
     "luma",
     "chroma",
     NULL);
 
   babl_component_new (
     "G'",
-   "id",    BABL_GREEN_GAMMA_2_2,
-   "luma", 
-   "chroma",
-   NULL);
-  
+    "id", BABL_GREEN_GAMMA_2_2,
+    "luma",
+    "chroma",
+    NULL);
+
   babl_component_new (
     "B'",
-   "id",    BABL_BLUE_GAMMA_2_2,
-   "luma",
-   "chroma",
-   NULL);
+    "id", BABL_BLUE_GAMMA_2_2,
+    "luma",
+    "chroma",
+    NULL);
 
   babl_component_new (
     "R'a",
-   "id",    BABL_RED_GAMMA_2_2_MUL_ALPHA,
+    "id", BABL_RED_GAMMA_2_2_MUL_ALPHA,
     "luma",
     "chroma",
     NULL);
 
   babl_component_new (
     "G'a",
-   "id",    BABL_GREEN_GAMMA_2_2_MUL_ALPHA,
-   "luma", 
-   "chroma",
-   NULL);
-  
+    "id", BABL_GREEN_GAMMA_2_2_MUL_ALPHA,
+    "luma",
+    "chroma",
+    NULL);
+
   babl_component_new (
     "B'a",
-   "id",    BABL_BLUE_GAMMA_2_2_MUL_ALPHA,
-   "luma",
-   "chroma",
-   NULL);
+    "id", BABL_BLUE_GAMMA_2_2_MUL_ALPHA,
+    "luma",
+    "chroma",
+    NULL);
 }
 
 static void
 models (void)
 {
-
   babl_model_new (
     "id", BABL_RGB,
     babl_component_id (BABL_RED),
@@ -119,7 +115,7 @@ models (void)
     babl_component_id (BABL_BLUE),
     NULL);
 
-    babl_model_new (
+  babl_model_new (
     "id", BABL_RGBA_PREMULTIPLIED,
     babl_component_id (BABL_RED_MUL_ALPHA),
     babl_component_id (BABL_GREEN_MUL_ALPHA),
@@ -160,20 +156,21 @@ copy_strip_1 (int    src_bands,
               int   *dst_pitch,
               long   samples)
 {
-  long n=samples; 
+  long n = samples;
+
   BABL_PLANAR_SANITY
   while (n--)
     {
       int i;
 
-      for (i=0;i<dst_bands;i++)
+      for (i = 0; i < dst_bands; i++)
         {
           double foo;
-          if (i<src_bands)
+          if (i < src_bands)
             foo = *(double *) src[i];
           else
             foo = 1.0;
-          *(double*)dst[i] = foo;
+          *(double *) dst[i] = foo;
         }
 
       BABL_PLANAR_STEP
@@ -190,15 +187,16 @@ g3_gamma_2_2 (int    src_bands,
               int   *dst_pitch,
               long   samples)
 {
-  long n=samples;
+  long n = samples;
+
   BABL_PLANAR_SANITY
   while (n--)
     {
       int band;
-      for (band=0;band<3;band++)
-        *(double*)dst[band] = linear_to_gamma_2_2 (*(double*) src[band]);
-      for (;band<dst_bands;band++)
-        *(double*)dst[band] = *(double*) src[band];
+      for (band = 0; band < 3; band++)
+        *(double *) dst[band] = linear_to_gamma_2_2 (*(double *) src[band]);
+      for (; band < dst_bands; band++)
+        *(double *) dst[band] = *(double *) src[band];
 
       BABL_PLANAR_STEP
     }
@@ -215,21 +213,22 @@ g3_inv_gamma_2_2 (int    src_bands,
                   int   *dst_pitch,
                   long   samples)
 {
-  long n=samples;
+  long n = samples;
+
   BABL_PLANAR_SANITY
   while (n--)
     {
       int band;
-      for (band=0;band<3;band++)
+      for (band = 0; band < 3; band++)
         {
-          *(double*)dst[band] = gamma_2_2_to_linear (*(double*) src[band]);
+          *(double *) dst[band] = gamma_2_2_to_linear (*(double *) src[band]);
         }
-      for (;band<dst_bands;band++)
+      for (; band < dst_bands; band++)
         {
-          if (band<src_bands)
-            *(double*)dst[band] = *(double*) src[band];
+          if (band < src_bands)
+            *(double *) dst[band] = *(double *) src[band];
           else
-            *(double*)dst[band] = 1.0;
+            *(double *) dst[band] = 1.0;
         }
       BABL_PLANAR_STEP
     }
@@ -245,19 +244,20 @@ non_premultiplied_to_premultiplied (int    src_bands,
                                     int   *dst_pitch,
                                     long   samples)
 {
-  long n=samples; 
+  long n = samples;
+
   BABL_PLANAR_SANITY
   while (n--)
     {
       double alpha;
-      int band;
+      int    band;
 
-      alpha = *(double *)src[src_bands-1];
-      for (band=0; band<src_bands-1;band++)
+      alpha = *(double *) src[src_bands - 1];
+      for (band = 0; band < src_bands - 1; band++)
         {
-          *(double*)dst[band] = *(double*) src[band] * alpha;
+          *(double *) dst[band] = *(double *) src[band] * alpha;
         }
-      *(double*)dst[dst_bands-1] = alpha;
+      *(double *) dst[dst_bands - 1] = alpha;
 
       BABL_PLANAR_STEP
     }
@@ -273,26 +273,27 @@ premultiplied_to_non_premultiplied (int    src_bands,
                                     int   *dst_pitch,
                                     long   samples)
 {
-  long n=samples; 
+  long n = samples;
+
   BABL_PLANAR_SANITY
   while (n--)
     {
       double alpha;
-      int band;
+      int    band;
 
-      alpha = *(double *)src[src_bands-1];
-      for (band=0; band<src_bands-1;band++)
+      alpha = *(double *) src[src_bands - 1];
+      for (band = 0; band < src_bands - 1; band++)
         {
-          if (alpha>0.001)
+          if (alpha > 0.001)
             {
-              *(double*)dst[band] = *(double*) src[band] / alpha;
+              *(double *) dst[band] = *(double *) src[band] / alpha;
             }
           else
             {
-              *(double*)dst[band] = 0.00;
+              *(double *) dst[band] = 0.00;
             }
         }
-      *(double*)dst[dst_bands-1] = alpha;
+      *(double *) dst[dst_bands - 1] = alpha;
 
       BABL_PLANAR_STEP
     }
@@ -306,16 +307,17 @@ rgba2rgba_gamma_2_2_premultiplied (char *src,
                                    char *dst,
                                    long  samples)
 {
-  long n=samples; 
+  long n = samples;
+
   while (n--)
     {
-      double alpha = ((double*)src)[3];
-      ((double*)dst)[0] = linear_to_gamma_2_2 (((double*) src)[0]) * alpha;
-      ((double*)dst)[1] = linear_to_gamma_2_2 (((double*) src)[1]) * alpha;
-      ((double*)dst)[2] = linear_to_gamma_2_2 (((double*) src)[2]) * alpha;
-      ((double*)dst)[3] = alpha;
-      src+=4 * sizeof (double);
-      dst+=4 * sizeof (double);
+      double alpha = ((double *) src)[3];
+      ((double *) dst)[0] = linear_to_gamma_2_2 (((double *) src)[0]) * alpha;
+      ((double *) dst)[1] = linear_to_gamma_2_2 (((double *) src)[1]) * alpha;
+      ((double *) dst)[2] = linear_to_gamma_2_2 (((double *) src)[2]) * alpha;
+      ((double *) dst)[3] = alpha;
+      src                += 4 * sizeof (double);
+      dst                += 4 * sizeof (double);
     }
   return samples;
 }
@@ -324,28 +326,29 @@ rgba2rgba_gamma_2_2_premultiplied (char *src,
 static long
 rgba_gamma_2_2_premultiplied2rgba (char *src,
                                    char *dst,
-                                   long   samples)
+                                   long  samples)
 {
-  long n=samples; 
+  long n = samples;
+
   while (n--)
     {
-      double alpha = ((double*) src)[3];
-    if (alpha > 0.0001)
+      double alpha = ((double *) src)[3];
+      if (alpha > 0.0001)
         {
-          ((double*)dst)[0] = gamma_2_2_to_linear (((double*) src)[0] / alpha);
-          ((double*)dst)[1] = gamma_2_2_to_linear (((double*) src)[1] / alpha);
-          ((double*)dst)[2] = gamma_2_2_to_linear (((double*) src)[2] / alpha);
+          ((double *) dst)[0] = gamma_2_2_to_linear (((double *) src)[0] / alpha);
+          ((double *) dst)[1] = gamma_2_2_to_linear (((double *) src)[1] / alpha);
+          ((double *) dst)[2] = gamma_2_2_to_linear (((double *) src)[2] / alpha);
         }
       else
         {
-          ((double*)dst)[0] = 0.0;
-          ((double*)dst)[1] = 0.0;
-          ((double*)dst)[2] = 0.0;
+          ((double *) dst)[0] = 0.0;
+          ((double *) dst)[1] = 0.0;
+          ((double *) dst)[2] = 0.0;
         }
-      ((double*)dst)[3] = alpha;
+      ((double *) dst)[3] = alpha;
 
-      src+=4 * sizeof (double);
-      dst+=4 * sizeof (double);
+      src += 4 * sizeof (double);
+      dst += 4 * sizeof (double);
     }
   return samples;
 }
@@ -356,16 +359,17 @@ rgba2rgba_gamma_2_2 (char *src,
                      char *dst,
                      long  samples)
 {
-  long n=samples; 
+  long n = samples;
+
   while (n--)
     {
-      double alpha = ((double*)src)[3];
-      ((double*)dst)[0] = linear_to_gamma_2_2 (((double*) src)[0]);
-      ((double*)dst)[1] = linear_to_gamma_2_2 (((double*) src)[1]);
-      ((double*)dst)[2] = linear_to_gamma_2_2 (((double*) src)[2]);
-      ((double*)dst)[3] = alpha;
-      src+=4 * sizeof (double);
-      dst+=4 * sizeof (double);
+      double alpha = ((double *) src)[3];
+      ((double *) dst)[0] = linear_to_gamma_2_2 (((double *) src)[0]);
+      ((double *) dst)[1] = linear_to_gamma_2_2 (((double *) src)[1]);
+      ((double *) dst)[2] = linear_to_gamma_2_2 (((double *) src)[2]);
+      ((double *) dst)[3] = alpha;
+      src                += 4 * sizeof (double);
+      dst                += 4 * sizeof (double);
     }
   return samples;
 }
@@ -376,18 +380,18 @@ rgba_gamma_2_22rgba (char *src,
                      char *dst,
                      long  samples)
 {
-  long n=samples;
-  
+  long n = samples;
+
   while (n--)
     {
-      double alpha = ((double*) src)[3];
-      ((double*)dst)[0] = gamma_2_2_to_linear (((double*) src)[0]);
-      ((double*)dst)[1] = gamma_2_2_to_linear (((double*) src)[1]);
-      ((double*)dst)[2] = gamma_2_2_to_linear (((double*) src)[2]);
-      ((double*)dst)[3] = alpha;
-
-      src+=4 * sizeof (double);
-      dst+=4 * sizeof (double);
+      double alpha = ((double *) src)[3];
+      ((double *) dst)[0] = gamma_2_2_to_linear (((double *) src)[0]);
+      ((double *) dst)[1] = gamma_2_2_to_linear (((double *) src)[1]);
+      ((double *) dst)[2] = gamma_2_2_to_linear (((double *) src)[2]);
+      ((double *) dst)[3] = alpha;
+
+      src += 4 * sizeof (double);
+      dst += 4 * sizeof (double);
     }
   return samples;
 }
@@ -398,7 +402,7 @@ conversions (void)
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_RGBA),
-    "planar",      copy_strip_1,
+    "planar", copy_strip_1,
     NULL
   );
 
@@ -406,41 +410,41 @@ conversions (void)
   babl_conversion_new (
     babl_model_id (BABL_RGB),
     babl_model_id (BABL_RGBA),
-    "planar",      copy_strip_1,
+    "planar", copy_strip_1,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_RGB),
-    "planar",      copy_strip_1,
+    "planar", copy_strip_1,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_RGBA_PREMULTIPLIED),
-    "planar",      non_premultiplied_to_premultiplied,
+    "planar", non_premultiplied_to_premultiplied,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA_PREMULTIPLIED),
     babl_model_id (BABL_RGBA),
-    "planar",      premultiplied_to_non_premultiplied,
+    "planar", premultiplied_to_non_premultiplied,
     NULL
   );
 
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_RGB_GAMMA_2_2),
-    "planar",      g3_gamma_2_2,
+    "planar", g3_gamma_2_2,
     NULL
   );
   babl_conversion_new (
     babl_model_id (BABL_RGB_GAMMA_2_2),
     babl_model_id (BABL_RGBA),
-    "planar",      g3_inv_gamma_2_2,
+    "planar", g3_inv_gamma_2_2,
     NULL
   );
 
@@ -465,17 +469,16 @@ conversions (void)
     babl_model_id (BABL_RGBA),
     "linear", rgba_gamma_2_2_premultiplied2rgba,
     NULL);
-  
 }
 
 static void
 formats (void)
 {
-    babl_format_new (
+  babl_format_new (
     //"name", "srgb",
     "id", BABL_SRGB,
-    babl_model_id     (BABL_RGB_GAMMA_2_2),
-    babl_type_id      (BABL_U8),
+    babl_model_id (BABL_RGB_GAMMA_2_2),
+    babl_type_id (BABL_U8),
     babl_component_id (BABL_RED_GAMMA_2_2),
     babl_component_id (BABL_GREEN_GAMMA_2_2),
     babl_component_id (BABL_BLUE_GAMMA_2_2),
@@ -483,8 +486,8 @@ formats (void)
 
   babl_format_new (
     "id", BABL_SRGBA,
-    babl_model_id     (BABL_RGBA_GAMMA_2_2),
-    babl_type_id      (BABL_U8),
+    babl_model_id (BABL_RGBA_GAMMA_2_2),
+    babl_type_id (BABL_U8),
     babl_component_id (BABL_RED_GAMMA_2_2),
     babl_component_id (BABL_GREEN_GAMMA_2_2),
     babl_component_id (BABL_BLUE_GAMMA_2_2),
@@ -492,30 +495,30 @@ formats (void)
     NULL);
 
   babl_format_new (
-    "id",              BABL_RGBA_FLOAT,
-    babl_model_id     (BABL_RGBA),
-    babl_type_id      (BABL_FLOAT),
-    babl_component_id (BABL_RED), 
-    babl_component_id (BABL_GREEN), 
+    "id", BABL_RGBA_FLOAT,
+    babl_model_id (BABL_RGBA),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
     babl_component_id (BABL_BLUE),
     babl_component_id (BABL_ALPHA),
     NULL);
 
   babl_format_new (
     "id", BABL_RGB_FLOAT,
-    babl_model_id     (BABL_RGB),
-    babl_type_id      (BABL_FLOAT),
-    babl_component_id (BABL_RED), 
-    babl_component_id (BABL_GREEN), 
+    babl_model_id (BABL_RGB),
+    babl_type_id (BABL_FLOAT),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
     babl_component_id (BABL_BLUE),
     NULL);
 
 #ifdef XXXX
   babl_format_new (
     "id", BABL_RGB565,
-     babl_model_id (BABL_RGB),
-    babl_component_id (BABL_RED), 
-    babl_component_id (BABL_GREEN), 
+    babl_model_id (BABL_RGB),
+    babl_component_id (BABL_RED),
+    babl_component_id (BABL_GREEN),
     babl_component_id (BABL_BLUE),
 
   );
index 8aec9c82aca39eb26bd64eb7a3aa5f7f91f86686..ace76acfa195c1116d10f26c3da0b929b5f76f59 100644 (file)
 
 #include "util.h"
 
-static void components    (void);
-static void models        (void);
-static void conversions   (void);
+static void components (void);
+static void models (void);
+static void conversions (void);
 static void formats (void);
 
 void
 babl_base_model_ycbcr (void)
 {
-  components    ();
-  models        ();
-  conversions   ();
-  formats       ();
+  components ();
+  models ();
+  conversions ();
+  formats ();
 }
 
 static void
 components (void)
 {
   babl_component_new (
-   "Cb",
-   "id", BABL_CB,
-   "chroma",
-   NULL);
+    "Cb",
+    "id", BABL_CB,
+    "chroma",
+    NULL);
 
   babl_component_new (
-   "Cr",
-   "id", BABL_CR,
-   "chroma",
-   NULL);
+    "Cr",
+    "id", BABL_CR,
+    "chroma",
+    NULL);
 }
 
 static void
@@ -82,25 +82,25 @@ rgba_to_ycbcra (char *src,
 {
   while (n--)
     {
-      double red   = ((double*)src)[0];
-      double green = ((double*)src)[1];
-      double blue  = ((double*)src)[2];
-      double alpha = ((double*)src)[3];
+      double red   = ((double *) src)[0];
+      double green = ((double *) src)[1];
+      double blue  = ((double *) src)[2];
+      double alpha = ((double *) src)[3];
 
       double luminance, cb, cr;
 
       red   = linear_to_gamma_2_2 (red);
       green = linear_to_gamma_2_2 (green);
       blue  = linear_to_gamma_2_2 (blue);
-      
-      luminance =  0.299    * red  +0.587    * green  +0.114    * blue;
-      cb        = -0.168736 * red  -0.331264 * green  +0.5      * blue;
-      cr        =  0.5      * red  -0.418688 * green  -0.081312 * blue;
 
-      ((double*)dst)[0] = luminance;
-      ((double*)dst)[1] = cb;
-      ((double*)dst)[2] = cr;
-      ((double*)dst)[3] = alpha;
+      luminance = 0.299 * red + 0.587 * green + 0.114 * blue;
+      cb        = -0.168736 * red - 0.331264 * green + 0.5 * blue;
+      cr        = 0.5 * red - 0.418688 * green - 0.081312 * blue;
+
+      ((double *) dst)[0] = luminance;
+      ((double *) dst)[1] = cb;
+      ((double *) dst)[2] = cr;
+      ((double *) dst)[3] = alpha;
 
       src += sizeof (double) * 4;
       dst += sizeof (double) * 4;
@@ -116,23 +116,23 @@ rgba_to_ycbcr (char *src,
 {
   while (n--)
     {
-      double red   = ((double*)src)[0];
-      double green = ((double*)src)[1];
-      double blue  = ((double*)src)[2];
+      double red   = ((double *) src)[0];
+      double green = ((double *) src)[1];
+      double blue  = ((double *) src)[2];
 
       double luminance, cb, cr;
 
       red   = linear_to_gamma_2_2 (red);
       green = linear_to_gamma_2_2 (green);
       blue  = linear_to_gamma_2_2 (blue);
-      
-      luminance =  0.299    * red  +0.587    * green  +0.114    * blue;
-      cb        = -0.168736 * red  -0.331264 * green  +0.5      * blue;
-      cr        =  0.5      * red  -0.418688 * green  -0.081312 * blue;
 
-      ((double*)dst)[0] = luminance;
-      ((double*)dst)[1] = cb;
-      ((double*)dst)[2] = cr;
+      luminance = 0.299 * red + 0.587 * green + 0.114 * blue;
+      cb        = -0.168736 * red - 0.331264 * green + 0.5 * blue;
+      cr        = 0.5 * red - 0.418688 * green - 0.081312 * blue;
+
+      ((double *) dst)[0] = luminance;
+      ((double *) dst)[1] = cb;
+      ((double *) dst)[2] = cr;
 
       src += sizeof (double) * 4;
       dst += sizeof (double) * 3;
@@ -147,25 +147,25 @@ ycbcra_to_rgba (char *src,
 {
   while (n--)
     {
-      double luminance = ((double*)src)[0];
-      double cb        = ((double*)src)[1];
-      double cr        = ((double*)src)[2];
-      double alpha     = ((double*)src)[3];
+      double luminance = ((double *) src)[0];
+      double cb        = ((double *) src)[1];
+      double cr        = ((double *) src)[2];
+      double alpha     = ((double *) src)[3];
 
       double red, green, blue;
 
-      red   = 1.0 * luminance  + 0.0      * cb  + 1.40200    * cr;
-      green = 1.0 * luminance  - 0.344136 * cb  - 0.71414136 * cr;
-      blue  = 1.0 * luminance  + 1.772    * cb  + 0.0        * cr;
+      red   = 1.0 * luminance + 0.0 * cb + 1.40200 * cr;
+      green = 1.0 * luminance - 0.344136 * cb - 0.71414136 * cr;
+      blue  = 1.0 * luminance + 1.772 * cb + 0.0 * cr;
 
       red   = gamma_2_2_to_linear (red);
       green = gamma_2_2_to_linear (green);
       blue  = gamma_2_2_to_linear (blue);
 
-      ((double*)dst)[0] = red;
-      ((double*)dst)[1] = green;
-      ((double*)dst)[2] = blue;
-      ((double*)dst)[3] = alpha;
+      ((double *) dst)[0] = red;
+      ((double *) dst)[1] = green;
+      ((double *) dst)[2] = blue;
+      ((double *) dst)[3] = alpha;
 
       src += sizeof (double) * 4;
       dst += sizeof (double) * 4;
@@ -181,24 +181,24 @@ ycbcr_to_rgba (char *src,
 {
   while (n--)
     {
-      double luminance = ((double*)src)[0];
-      double cb        = ((double*)src)[1];
-      double cr        = ((double*)src)[2];
+      double luminance = ((double *) src)[0];
+      double cb        = ((double *) src)[1];
+      double cr        = ((double *) src)[2];
 
       double red, green, blue;
 
-      red   = 1.0 * luminance  + 0.0      * cb  + 1.40200    * cr;
-      green = 1.0 * luminance  - 0.344136 * cb  - 0.71414136 * cr;
-      blue  = 1.0 * luminance  + 1.772    * cb  + 0.0        * cr;
+      red   = 1.0 * luminance + 0.0 * cb + 1.40200 * cr;
+      green = 1.0 * luminance - 0.344136 * cb - 0.71414136 * cr;
+      blue  = 1.0 * luminance + 1.772 * cb + 0.0 * cr;
 
       red   = gamma_2_2_to_linear (red);
       green = gamma_2_2_to_linear (green);
       blue  = gamma_2_2_to_linear (blue);
 
-      ((double*)dst)[0] = red;
-      ((double*)dst)[1] = green;
-      ((double*)dst)[2] = blue;
-      ((double*)dst)[3] = 1.0;
+      ((double *) dst)[0] = red;
+      ((double *) dst)[1] = green;
+      ((double *) dst)[2] = blue;
+      ((double *) dst)[3] = 1.0;
 
       src += sizeof (double) * 3;
       dst += sizeof (double) * 4;
@@ -212,25 +212,25 @@ conversions (void)
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_YCBCR),
-    "linear",      rgba_to_ycbcr,
+    "linear", rgba_to_ycbcr,
     NULL
   );
   babl_conversion_new (
     babl_model_id (BABL_YCBCR),
     babl_model_id (BABL_RGBA),
-    "linear",      ycbcr_to_rgba,
+    "linear", ycbcr_to_rgba,
     NULL
   );
   babl_conversion_new (
     babl_model_id (BABL_RGBA),
     babl_model_id (BABL_YCBCR_ALPHA),
-    "linear",      rgba_to_ycbcra,
+    "linear", rgba_to_ycbcra,
     NULL
   );
   babl_conversion_new (
     babl_model_id (BABL_YCBCR_ALPHA),
     babl_model_id (BABL_RGBA),
-    "linear",      ycbcra_to_rgba,
+    "linear", ycbcra_to_rgba,
     NULL
   );
 }
@@ -239,64 +239,64 @@ static void
 formats (void)
 {
   babl_format_new (
-    "name",        "Y'CbCr u8",
-    "id",          BABL_YCBCR420,
+    "name", "Y'CbCr u8",
+    "id", BABL_YCBCR420,
     "planar",
-    babl_model_id  (BABL_YCBCR),
-    babl_type_id   (BABL_U8_LUMA),
-    babl_sampling  (1, 1),
+    babl_model_id (BABL_YCBCR),
+    babl_type_id (BABL_U8_LUMA),
+    babl_sampling (1, 1),
     babl_component_id (BABL_LUMA),
-    babl_type_id   (BABL_U8_CHROMA),
-    babl_sampling  (2, 2),
-    babl_component_id (BABL_CB), 
-    babl_sampling  (2, 2),
+    babl_type_id (BABL_U8_CHROMA),
+    babl_sampling (2, 2),
+    babl_component_id (BABL_CB),
+    babl_sampling (2, 2),
     babl_component_id (BABL_CR),
     NULL);
   return;
 
   babl_format_new (
-    "name",        "y'cbcr420",
-    "id",          BABL_YCBCR420,
+    "name", "y'cbcr420",
+    "id", BABL_YCBCR420,
     "planar",
-    babl_model_id  (BABL_YCBCR),
-    babl_type_id   (BABL_U8_LUMA),
-    babl_sampling  (1, 1),
+    babl_model_id (BABL_YCBCR),
+    babl_type_id (BABL_U8_LUMA),
+    babl_sampling (1, 1),
     babl_component_id (BABL_LUMA),
-    babl_type_id   (BABL_U8_CHROMA),
-    babl_sampling  (2, 2),
-    babl_component_id (BABL_CB), 
-    babl_sampling  (2, 2),
+    babl_type_id (BABL_U8_CHROMA),
+    babl_sampling (2, 2),
+    babl_component_id (BABL_CB),
+    babl_sampling (2, 2),
     babl_component_id (BABL_CR),
     NULL);
-  
+
 
   babl_format_new (
-    "name",        "y'cbcr422",
-    "id",          BABL_YCBCR422,
+    "name", "y'cbcr422",
+    "id", BABL_YCBCR422,
     "planar",
-    babl_model_id  (BABL_YCBCR),
-    babl_type_id   (BABL_U8_LUMA),
-    babl_sampling  (1, 1),
+    babl_model_id (BABL_YCBCR),
+    babl_type_id (BABL_U8_LUMA),
+    babl_sampling (1, 1),
     babl_component_id (BABL_LUMA),
-    babl_type_id   (BABL_U8_CHROMA),
-    babl_sampling  (2, 1),
-    babl_component_id (BABL_CB), 
-    babl_sampling  (2, 1),
+    babl_type_id (BABL_U8_CHROMA),
+    babl_sampling (2, 1),
+    babl_component_id (BABL_CB),
+    babl_sampling (2, 1),
     babl_component_id (BABL_CR),
     NULL);
 
   babl_format_new (
-    "name",        "y'cbcr411",
-    "id",          BABL_YCBCR411,
+    "name", "y'cbcr411",
+    "id", BABL_YCBCR411,
     "planar",
-    babl_model_id  (BABL_YCBCR),
-    babl_type_id   (BABL_U8_LUMA),
-    babl_sampling  (1, 1),
+    babl_model_id (BABL_YCBCR),
+    babl_type_id (BABL_U8_LUMA),
+    babl_sampling (1, 1),
     babl_component_id (BABL_LUMA),
-    babl_type_id   (BABL_U8_CHROMA),
-    babl_sampling  (4, 1),
-    babl_component_id (BABL_CB), 
-    babl_sampling  (4, 1),
+    babl_type_id (BABL_U8_CHROMA),
+    babl_sampling (4, 1),
+    babl_component_id (BABL_CB),
+    babl_sampling (4, 1),
     babl_component_id (BABL_CR),
     NULL);
 }
index a0b9d010f7598b566bd1a007fd1ae0d2d3fae9df..1bc90d255397f8c0404d3d7ab145ee2c4e1b20b0 100644 (file)
@@ -34,8 +34,8 @@ convert_double_float (char *src,
   while (n--)
     {
       (*(float *) dst) = (*(double *) src);
-      dst += dst_pitch;
-      src += src_pitch;
+      dst             += dst_pitch;
+      src             += src_pitch;
     }
   return n;
 }
@@ -50,8 +50,8 @@ convert_float_double (char *src,
   while (n--)
     {
       (*(double *) dst) = (*(float *) src);
-      dst += dst_pitch;
-      src += src_pitch;
+      dst              += dst_pitch;
+      src              += src_pitch;
     }
   return n;
 }
@@ -61,7 +61,7 @@ babl_base_type_float (void)
 {
   babl_type_new (
     "float",
-    "id",   BABL_FLOAT,
+    "id", BABL_FLOAT,
     "bits", 32,
     NULL);
 
index b0ac0a8a5131b86cde47d9ee298afd7129b766f5..46d18ce864e34b8383984f74b2f895c006841bee 100644 (file)
 
 
 static inline long
-convert_double_u16_scaled (double    min_val,
-                           double    max_val,
-                           uint16_t  min,
-                           uint16_t  max,
-                           char     *src,
-                           char     *dst,
-                           int       src_pitch,
-                           int       dst_pitch,
-                           long      n)
+convert_double_u16_scaled (double   min_val,
+                           double   max_val,
+                           uint16_t min,
+                           uint16_t max,
+                           char    *src,
+                           char    *dst,
+                           int      src_pitch,
+                           int      dst_pitch,
+                           long     n)
 {
   while (n--)
     {
@@ -48,29 +48,29 @@ convert_double_u16_scaled (double    min_val,
       else if (dval > max_val)
         u16val = max;
       else
-        u16val = rint((dval-min_val) / (max_val-min_val) * (max-min) + min);
+        u16val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min);
 
       *(uint16_t *) dst = u16val;
-      dst += dst_pitch;
-      src += src_pitch;
+      dst              += dst_pitch;
+      src              += src_pitch;
     }
   return n;
 }
 
 static inline long
-convert_u16_double_scaled (double    min_val,
-                           double    max_val,
-                           uint16_t  min,
-                           uint16_t  max,
-                           char     *src,
-                           char     *dst,
-                           int       src_pitch,
-                           int       dst_pitch,
-                           long      n)
+convert_u16_double_scaled (double   min_val,
+                           double   max_val,
+                           uint16_t min,
+                           uint16_t max,
+                           char    *src,
+                           char    *dst,
+                           int      src_pitch,
+                           int      dst_pitch,
+                           long     n)
 {
   while (n--)
     {
-      int    u16val = *(uint16_t*) src;
+      int    u16val = *(uint16_t *) src;
       double dval;
 
       if (u16val < min)
@@ -78,45 +78,45 @@ convert_u16_double_scaled (double    min_val,
       else if (u16val > max)
         dval = max_val;
       else
-        dval  = (u16val-min) / (double)(max-min) * (max_val-min_val) + min_val;
+        dval = (u16val - min) / (double) (max - min) * (max_val - min_val) + min_val;
 
       (*(double *) dst) = dval;
-      dst += dst_pitch;
-      src += src_pitch;
+      dst              += dst_pitch;
+      src              += src_pitch;
     }
   return n;
 }
 
 #define MAKE_CONVERSIONS(name, min_val, max_val, min, max)      \
-static long                                                     \
-convert_##name##_double (void *src,                             \
-                         void *dst,                             \
-                         int   src_pitch,                       \
-                         int   dst_pitch,                       \
-                         long  n)                               \
-{                                                               \
-  return convert_u16_double_scaled (min_val, max_val, min, max, \
-                             src, dst, src_pitch, dst_pitch, n);\
-}                                                               \
-static long                                                     \
-convert_double_##name (void *src,                               \
-                       void *dst,                               \
-                       int   src_pitch,                         \
-                       int   dst_pitch,                         \
-                       long  n)                                 \
-{                                                               \
-  return convert_double_u16_scaled (min_val, max_val, min, max, \
-                             src, dst, src_pitch, dst_pitch, n);\
-}
+  static long \
+  convert_ ## name ## _double (void *src, \
+                               void *dst, \
+                               int src_pitch, \
+                               int dst_pitch, \
+                               long n)                               \
+  { \
+    return convert_u16_double_scaled (min_val, max_val, min, max, \
+                                      src, dst, src_pitch, dst_pitch, n); \
+  }                                                               \
+  static long \
+  convert_double_ ## name (void *src, \
+                           void *dst, \
+                           int src_pitch, \
+                           int dst_pitch, \
+                           long n)                                 \
+  { \
+    return convert_double_u16_scaled (min_val, max_val, min, max, \
+                                      src, dst, src_pitch, dst_pitch, n); \
+  }
 
-MAKE_CONVERSIONS(u16,0.0,1.0,0,UINT16_MAX);
+MAKE_CONVERSIONS (u16, 0.0, 1.0, 0, UINT16_MAX);
 
 void
 babl_base_type_u16 (void)
 {
   babl_type_new (
     "u16",
-    "id",   BABL_U16,
+    "id", BABL_U16,
     "bits", 16,
     NULL);
 
index 683c684dc184d8200fbeef5f05fe7b39059a9444..27b87a7b94d01da56aafd4725fe6e521fad57f3a 100644 (file)
 #include "babl-base.h"
 
 static inline long
-convert_double_u32_scaled (double    min_val,
-                           double    max_val,
-                           uint32_t  min,
-                           uint32_t  max,
-                           char     *src,
-                           char     *dst,
-                           int       src_pitch,
-                           int       dst_pitch,
-                           long      n)
+convert_double_u32_scaled (double   min_val,
+                           double   max_val,
+                           uint32_t min,
+                           uint32_t max,
+                           char    *src,
+                           char    *dst,
+                           int      src_pitch,
+                           int      dst_pitch,
+                           long     n)
 {
   while (n--)
     {
@@ -47,29 +47,29 @@ convert_double_u32_scaled (double    min_val,
       else if (dval > max_val)
         u32val = max;
       else
-        u32val = rint ((dval-min_val) / (max_val-min_val) * (max-min) + min);
+        u32val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min);
 
       *(uint32_t *) dst = u32val;
-      dst += dst_pitch;
-      src += src_pitch;
+      dst              += dst_pitch;
+      src              += src_pitch;
     }
   return n;
 }
 
 static inline long
-convert_u32_double_scaled (double    min_val,
-                           double    max_val,
-                           uint32_t  min,
-                           uint32_t  max,
-                           char     *src,
-                           char     *dst,
-                           int       src_pitch,
-                           int       dst_pitch,
-                           long      n)
+convert_u32_double_scaled (double   min_val,
+                           double   max_val,
+                           uint32_t min,
+                           uint32_t max,
+                           char    *src,
+                           char    *dst,
+                           int      src_pitch,
+                           int      dst_pitch,
+                           long     n)
 {
   while (n--)
     {
-      int    u32val = *(uint32_t*) src;
+      int    u32val = *(uint32_t *) src;
       double dval;
 
       if (u32val < min)
@@ -77,45 +77,45 @@ convert_u32_double_scaled (double    min_val,
       else if (u32val > max)
         dval = max_val;
       else
-        dval  = (u32val-min) / (double)(max-min) * (max_val-min_val) + min_val;
+        dval = (u32val - min) / (double) (max - min) * (max_val - min_val) + min_val;
 
       (*(double *) dst) = dval;
-      dst += dst_pitch;
-      src += src_pitch;
+      dst              += dst_pitch;
+      src              += src_pitch;
     }
   return n;
 }
 
 #define MAKE_CONVERSIONS(name, min_val, max_val, min, max)      \
-static long                                                     \
-convert_##name##_double (void *src,                             \
-                         void *dst,                             \
-                         int   src_pitch,                       \
-                         int   dst_pitch,                       \
-                         long  n)                               \
-{                                                               \
-  return convert_u32_double_scaled (min_val, max_val, min, max, \
-                             src, dst, src_pitch, dst_pitch, n);\
-}                                                               \
-static long                                                     \
-convert_double_##name (void *src,                               \
-                       void *dst,                               \
-                       int   src_pitch,                         \
-                       int   dst_pitch,                         \
-                       long  n)                                 \
-{                                                               \
-  return convert_double_u32_scaled (min_val, max_val, min, max, \
-                             src, dst, src_pitch, dst_pitch, n);\
-}
+  static long \
+  convert_ ## name ## _double (void *src, \
+                               void *dst, \
+                               int src_pitch, \
+                               int dst_pitch, \
+                               long n)                               \
+  { \
+    return convert_u32_double_scaled (min_val, max_val, min, max, \
+                                      src, dst, src_pitch, dst_pitch, n); \
+  }                                                               \
+  static long \
+  convert_double_ ## name (void *src, \
+                           void *dst, \
+                           int src_pitch, \
+                           int dst_pitch, \
+                           long n)                                 \
+  { \
+    return convert_double_u32_scaled (min_val, max_val, min, max, \
+                                      src, dst, src_pitch, dst_pitch, n); \
+  }
 
-MAKE_CONVERSIONS(u32,0.0,1.0,0,UINT32_MAX);
+MAKE_CONVERSIONS (u32, 0.0, 1.0, 0, UINT32_MAX);
 
 void
 babl_base_type_u32 (void)
 {
   babl_type_new (
     "u32",
-    "id",   BABL_U32,
+    "id", BABL_U32,
     "bits", 32,
     NULL);
 
index 1f3ee802cc058506c7353702df080e260ec55d7d..1c9f44be3d173ec04b48d695e50ca2d0e509448d 100644 (file)
@@ -39,7 +39,7 @@ convert_double_u8_scaled (double        min_val,
 {
   while (n--)
     {
-      double         dval = *(double *) src;
+      double        dval = *(double *) src;
       unsigned char u8val;
 
       if (dval < min_val)
@@ -47,11 +47,11 @@ convert_double_u8_scaled (double        min_val,
       else if (dval > max_val)
         u8val = max;
       else
-        u8val = rint ((dval-min_val) / (max_val-min_val) * (max-min) + min);
+        u8val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min);
 
       *(unsigned char *) dst = u8val;
-      src += src_pitch;
-      dst += dst_pitch;
+      src                   += src_pitch;
+      dst                   += dst_pitch;
     }
   return n;
 }
@@ -77,7 +77,7 @@ convert_u8_double_scaled (double        min_val,
       else if (u8val > max)
         dval = max_val;
       else
-        dval  = (u8val-min) / (double)(max-min) * (max_val-min_val) + min_val;
+        dval = (u8val - min) / (double) (max - min) * (max_val - min_val) + min_val;
 
       (*(double *) dst) = dval;
 
@@ -88,29 +88,29 @@ convert_u8_double_scaled (double        min_val,
 }
 
 #define MAKE_CONVERSIONS(name, min_val, max_val, min, max)      \
-static long                                                     \
-convert_##name##_double (void *src,                             \
-                         void *dst,                             \
-                         int   src_pitch,                       \
-                         int   dst_pitch,                       \
-                         long  n)                               \
-{                                                               \
-  return convert_u8_double_scaled (min_val, max_val, min, max,  \
-                            src, dst, src_pitch, dst_pitch, n); \
-}                                                               \
-static long                                                     \
-convert_double_##name (void *src,                               \
-                       void *dst,                               \
-                       int   src_pitch,                         \
-                       int   dst_pitch,                         \
-                       long  n)                                 \
-{                                                               \
-  return convert_double_u8_scaled (min_val, max_val, min, max,  \
-                            src, dst, src_pitch, dst_pitch, n); \
-}
+  static long \
+  convert_ ## name ## _double (void *src, \
+                               void *dst, \
+                               int src_pitch, \
+                               int dst_pitch, \
+                               long n)                               \
+  { \
+    return convert_u8_double_scaled (min_val, max_val, min, max, \
+                                     src, dst, src_pitch, dst_pitch, n); \
+  }                                                               \
+  static long \
+  convert_double_ ## name (void *src, \
+                           void *dst, \
+                           int src_pitch, \
+                           int dst_pitch, \
+                           long n)                                 \
+  { \
+    return convert_double_u8_scaled (min_val, max_val, min, max, \
+                                     src, dst, src_pitch, dst_pitch, n); \
+  }
 
-MAKE_CONVERSIONS (u8,        0.0, 1.0, 0x00, UINT8_MAX);
-MAKE_CONVERSIONS (u8_luma,   0.0, 1.0, 16, 235);
+MAKE_CONVERSIONS (u8, 0.0, 1.0, 0x00, UINT8_MAX);
+MAKE_CONVERSIONS (u8_luma, 0.0, 1.0, 16, 235);
 MAKE_CONVERSIONS (u8_chroma, 0.0, 1.0, 16, 240);
 
 void
@@ -118,63 +118,63 @@ babl_base_type_u8 (void)
 {
   babl_type_new (
     "u8",
-    "id",   BABL_U8,
+    "id", BABL_U8,
     "bits", 8,
     NULL);
 
   babl_type_new (
     "u8-luma",
-    "id",             BABL_U8_LUMA,
-    "bits",           8,
+    "id", BABL_U8_LUMA,
+    "bits", 8,
     NULL
   );
 
   babl_type_new (
     "u8-chroma",
-    "id",             BABL_U8_CHROMA,
+    "id", BABL_U8_CHROMA,
     "integer",
     "unsigned",
-    "bits",           8,
-    "min",    (long) 16,
-    "max",    (long)240,
-    "min_val",     -0.5,
-    "max_val",      0.5,
+    "bits", 8,
+    "min", (long) 16,
+    "max", (long) 240,
+    "min_val", -0.5,
+    "max_val", 0.5,
     NULL
   );
   babl_conversion_new (
     babl_type_id (BABL_U8),
     babl_type_id (BABL_DOUBLE),
-    "plane",      convert_u8_double,
+    "plane", convert_u8_double,
     NULL
   );
   babl_conversion_new (
     babl_type_id (BABL_DOUBLE),
     babl_type_id (BABL_U8),
-    "plane",      convert_double_u8,
+    "plane", convert_double_u8,
     NULL
   );
   babl_conversion_new (
     babl_type_id (BABL_U8_LUMA),
     babl_type_id (BABL_DOUBLE),
-    "plane",      convert_u8_luma_double,
+    "plane", convert_u8_luma_double,
     NULL
   );
   babl_conversion_new (
     babl_type_id (BABL_DOUBLE),
     babl_type_id (BABL_U8_LUMA),
-    "plane",      convert_double_u8_luma,
+    "plane", convert_double_u8_luma,
     NULL
   );
   babl_conversion_new (
     babl_type_id (BABL_U8_CHROMA),
     babl_type_id (BABL_DOUBLE),
-    "plane",      convert_u8_chroma_double,
+    "plane", convert_u8_chroma_double,
     NULL
   );
   babl_conversion_new (
     babl_type_id (BABL_DOUBLE),
     babl_type_id (BABL_U8_CHROMA),
-    "plane",      convert_double_u8_chroma,
+    "plane", convert_double_u8_chroma,
     NULL
   );
 }
index c106082b330d5d0b3b06f9dcf541ce2c19ff421a..33bf926052329c1aad2335a4ad63fd24d08081f5 100644 (file)
@@ -1,66 +1,68 @@
-/*\r
- * timeval.h    1.0 01/12/19\r
- *\r
- * Defines gettimeofday, timeval, etc. for Win32\r
- *\r
- * By Wu Yongwei\r
- *\r
- */\r
-\r
-#ifdef _WIN32\r
-\r
-#define WIN32_LEAN_AND_MEAN\r
-#include <windows.h>\r
-#include <time.h>\r
-\r
-#ifndef __GNUC__\r
-#define EPOCHFILETIME (116444736000000000i64)\r
-#else\r
-#define EPOCHFILETIME (116444736000000000LL)\r
-#endif\r
-\r
-struct timeval {\r
-    long tv_sec;        /* seconds */\r
-    long tv_usec;  /* microseconds */\r
-};\r
-\r
-struct timezone {\r
-    int tz_minuteswest; /* minutes W of Greenwich */\r
-    int tz_dsttime;     /* type of dst correction */\r
-};\r
-\r
-\r
-int gettimeofday(struct timeval *tv, struct timezone *tz)\r
-{\r
-    FILETIME        ft;\r
-    LARGE_INTEGER   li;\r
-    __int64         t;\r
-    static int      tzflag;\r
-\r
-    if (tv)\r
-    {\r
-        GetSystemTimeAsFileTime(&ft);\r
-        li.LowPart  = ft.dwLowDateTime;\r
-        li.HighPart = ft.dwHighDateTime;\r
-        t  = li.QuadPart;       /* In 100-nanosecond intervals */\r
-        t -= EPOCHFILETIME;     /* Offset to the Epoch time */\r
-        t /= 10;                /* In microseconds */\r
-        tv->tv_sec  = (long)(t / 1000000);\r
-        tv->tv_usec = (long)(t % 1000000);\r
-    }\r
-\r
-    if (tz)\r
-    {\r
-        if (!tzflag)\r
-        {\r
-            _tzset();\r
-            tzflag++;\r
-        }\r
-        tz->tz_minuteswest = _timezone / 60;\r
-        tz->tz_dsttime = _daylight;\r
-    }\r
-\r
-    return 0;\r
-}\r
-\r
-#endif /* _WIN32 */\r
+/*
+ * timeval.h    1.0 01/12/19
+ *
+ * Defines gettimeofday, timeval, etc. for Win32
+ *
+ * By Wu Yongwei
+ *
+ */
+
+#ifdef _WIN32
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <time.h>
+
+#ifndef __GNUC__
+#define EPOCHFILETIME    (116444736000000000i 64)
+#else
+#define EPOCHFILETIME    (116444736000000000LL)
+#endif
+
+struct timeval
+{
+  long tv_sec;          /* seconds */
+  long tv_usec;    /* microseconds */
+};
+
+struct timezone
+{
+  int tz_minuteswest;   /* minutes W of Greenwich */
+  int tz_dsttime;       /* type of dst correction */
+};
+
+
+int gettimeofday (struct timeval *tv, struct timezone *tz)
+{
+  FILETIME      ft;
+  LARGE_INTEGER li;
+  __int64       t;
+  static int    tzflag;
+
+  if (tv)
+    {
+      GetSystemTimeAsFileTime (&ft);
+      li.LowPart  = ft.dwLowDateTime;
+      li.HighPart = ft.dwHighDateTime;
+      t           = li.QuadPart;/* In 100-nanosecond intervals */
+      t          -= EPOCHFILETIME;/* Offset to the Epoch time */
+      t          /= 10;         /* In microseconds */
+      tv->tv_sec  = (long) (t / 1000000);
+      tv->tv_usec = (long) (t % 1000000);
+    }
+
+  if (tz)
+    {
+      if (!tzflag)
+        {
+          _tzset ();
+          tzflag++;
+        }
+      tz->tz_minuteswest = _timezone / 60;
+      tz->tz_dsttime     = _daylight;
+    }
+
+  return 0;
+}
+
+#endif /* _WIN32 */
index 83ae574f0ef89ebfa816a4c13ef0ef2616ba3511..42e6d7e956d0c62907ecdfb9a2aef6873334b3b6 100644 (file)
 
 int init (void);
 
-static void types         (void);
-static void components    (void);
-static void models        (void);
-static void conversions   (void);
-static void formats       (void);
+static void types (void);
+static void components (void);
+static void models (void);
+static void conversions (void);
+static void formats (void);
 
 int
 init (void)
 {
-  types         ();
-  components    ();
-  models        ();
-  formats       ();
-  conversions   ();
+  types ();
+  components ();
+  models ();
+  formats ();
+  conversions ();
   return 0;
 }
 
 static void
 components (void)
 {
-  babl_component_new ( "CIE L", NULL);
-  babl_component_new ( "CIE a", "chroma", NULL);
-  babl_component_new ( "CIE b", "chroma", NULL);
+  babl_component_new ("CIE L", NULL);
+  babl_component_new ("CIE a", "chroma", NULL);
+  babl_component_new ("CIE b", "chroma", NULL);
 }
 
 static void
@@ -67,46 +67,46 @@ models (void)
     NULL);
 }
 
-/***********    cpercep.h *********   */ 
+/***********    cpercep.h *********   */
 
 /*
-Copyright (C) 1997-2002 Adam D. Moss (the "Author").  All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is fur-
-nished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
-NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
-NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the Author of the
-Software shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in this Software without prior written authorization
-from the Author.
-*/
+   Copyright (C) 1997-2002 Adam D. Moss (the "Author").  All Rights Reserved.
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is fur-
+   nished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+   NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+   AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+   NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+   Except as contained in this notice, the name of the Author of the
+   Software shall not be used in advertising or otherwise to promote the sale,
+   use or other dealings in this Software without prior written authorization
+   from the Author.
+ */
 
 /*
-  cpercep.c: The CPercep Functions v0.9: 2002-02-10
-  Adam D. Moss: adam@gimp.org <http://www.foxbox.org/adam/code/cpercep/>
+   cpercep.c: The CPercep Functions v0.9: 2002-02-10
+   Adam D. Moss: adam@gimp.org <http://www.foxbox.org/adam/code/cpercep/>
 
-  TODO: document functions, rename erroneously-named arguments
-*/
+   TODO: document functions, rename erroneously-named arguments
+ */
 
 #ifndef __CPERCEP_H__
 #define __CPERCEP_H__
 
 
-void  cpercep_init         (void);
+void  cpercep_init (void);
 
 void  cpercep_rgb_to_space (double  inr,
                             double  ing,
@@ -127,20 +127,20 @@ void  cpercep_space_to_rgb (double  inr,
 /* This is in the header so that it can potentially be inlined. */
 static const double
 cpercep_distance_space (const double L1, const double a1, const double b1,
-                       const double L2, const double a2, const double b2)
+                        const double L2, const double a2, const double b2)
 {
   const double Ld = L1 - L2;
   const double ad = a1 - a2;
   const double bd = b1 - b2;
 
-  return (Ld*Ld + ad*ad + bd*bd);
+  return (Ld * Ld + ad * ad + bd * bd);
 }
 #endif
 
 
 #endif /* __CPERCEP_H__ */
 
-/***********   /cpercep.h *********   */ 
+/***********   /cpercep.h *********   */
 
 
 
@@ -151,20 +151,20 @@ rgba_to_lab (char *src,
 {
   while (n--)
     {
-      double red   = ((double*)src)[0];
-      double green = ((double*)src)[1];
-      double blue  = ((double*)src)[2];
+      double red   = ((double *) src)[0];
+      double green = ((double *) src)[1];
+      double blue  = ((double *) src)[2];
 
       double L, a, b;
 
       cpercep_rgb_to_space (red, green, blue, &L, &a, &b);
 
-      ((double*)dst)[0] = L;
-      ((double*)dst)[1] = a;
-      ((double*)dst)[2] = b;
+      ((double *) dst)[0] = L;
+      ((double *) dst)[1] = a;
+      ((double *) dst)[2] = b;
 
-      src += sizeof(double) * 4;
-      dst += sizeof(double) * 3;
+      src += sizeof (double) * 4;
+      dst += sizeof (double) * 3;
     }
   return n;
 }
@@ -176,21 +176,21 @@ lab_to_rgba (char *src,
 {
   while (n--)
     {
-      double L = ((double*)src)[0];
-      double a = ((double*)src)[1];
-      double b = ((double*)src)[2];
+      double L = ((double *) src)[0];
+      double a = ((double *) src)[1];
+      double b = ((double *) src)[2];
 
       double red, green, blue;
 
       cpercep_space_to_rgb (L, a, b, &red, &green, &blue);
 
-      ((double*)dst)[0] = red;
-      ((double*)dst)[1] = green;
-      ((double*)dst)[2] = blue;
-      ((double*)dst)[3] = 1.0;
+      ((double *) dst)[0] = red;
+      ((double *) dst)[1] = green;
+      ((double *) dst)[2] = blue;
+      ((double *) dst)[3] = 1.0;
 
-      src += sizeof(double) * 3;
-      dst += sizeof(double) * 4;
+      src += sizeof (double) * 3;
+      dst += sizeof (double) * 4;
     }
   return n;
 }
@@ -203,22 +203,22 @@ rgba_to_laba (char *src,
 {
   while (n--)
     {
-      double red   = ((double*)src)[0];
-      double green = ((double*)src)[1];
-      double blue  = ((double*)src)[2];
-      double alpha = ((double*)src)[3];
+      double red   = ((double *) src)[0];
+      double green = ((double *) src)[1];
+      double blue  = ((double *) src)[2];
+      double alpha = ((double *) src)[3];
 
       double L, a, b;
 
       cpercep_rgb_to_space (red, green, blue, &L, &a, &b);
 
-      ((double*)dst)[0] = L;
-      ((double*)dst)[1] = a;
-      ((double*)dst)[2] = b;
-      ((double*)dst)[3] = alpha;
+      ((double *) dst)[0] = L;
+      ((double *) dst)[1] = a;
+      ((double *) dst)[2] = b;
+      ((double *) dst)[3] = alpha;
 
-      src += sizeof(double) * 4;
-      dst += sizeof(double) * 4;
+      src += sizeof (double) * 4;
+      dst += sizeof (double) * 4;
     }
   return n;
 }
@@ -230,22 +230,22 @@ laba_to_rgba (char *src,
 {
   while (n--)
     {
-      double L     = ((double*)src)[0];
-      double a     = ((double*)src)[1];
-      double b     = ((double*)src)[2];
-      double alpha = ((double*)src)[3];
+      double L     = ((double *) src)[0];
+      double a     = ((double *) src)[1];
+      double b     = ((double *) src)[2];
+      double alpha = ((double *) src)[3];
 
       double red, green, blue;
 
       cpercep_space_to_rgb (L, a, b, &red, &green, &blue);
 
-      ((double*)dst)[0] = red;
-      ((double*)dst)[1] = green;
-      ((double*)dst)[2] = blue;
-      ((double*)dst)[3] = alpha;
+      ((double *) dst)[0] = red;
+      ((double *) dst)[1] = green;
+      ((double *) dst)[2] = blue;
+      ((double *) dst)[3] = alpha;
 
-      src += sizeof(double) * 4;
-      dst += sizeof(double) * 4;
+      src += sizeof (double) * 4;
+      dst += sizeof (double) * 4;
     }
   return n;
 }
@@ -253,80 +253,79 @@ laba_to_rgba (char *src,
 static void
 conversions (void)
 {
-
   babl_conversion_new (
     babl_model ("RGBA"),
     babl_model ("CIE Lab"),
-    "linear",      rgba_to_lab,
+    "linear", rgba_to_lab,
     NULL
   );
   babl_conversion_new (
     babl_model ("CIE Lab"),
     babl_model ("RGBA"),
-    "linear",      lab_to_rgba,
+    "linear", lab_to_rgba,
     NULL
   );
   babl_conversion_new (
     babl_model ("RGBA"),
     babl_model ("CIE Lab alpha"),
-    "linear",      rgba_to_laba,
+    "linear", rgba_to_laba,
     NULL
   );
   babl_conversion_new (
     babl_model ("CIE Lab alpha"),
     babl_model ("RGBA"),
-    "linear",      laba_to_rgba,
+    "linear", laba_to_rgba,
     NULL
   );
 
-  cpercep_init  ();
+  cpercep_init ();
 }
 
 static void
 formats (void)
 {
   babl_format_new (
-    "name",        "CIE Lab float",
-    babl_model     ("CIE Lab"),
+    "name", "CIE Lab float",
+    babl_model ("CIE Lab"),
 
-    babl_type      ("float"),
-    babl_component ("CIE L"), 
-    babl_component ("CIE a"), 
+    babl_type ("float"),
+    babl_component ("CIE L"),
+    babl_component ("CIE a"),
     babl_component ("CIE b"),
     NULL);
 
   babl_format_new (
-    "name",        "CIE Lab alpha float",
-    babl_model     ("CIE Lab alpha"),
+    "name", "CIE Lab alpha float",
+    babl_model ("CIE Lab alpha"),
 
-    babl_type      ("double"),
-    babl_component ("CIE L"), 
-    babl_component ("CIE a"), 
+    babl_type ("double"),
+    babl_component ("CIE L"),
+    babl_component ("CIE a"),
     babl_component ("CIE b"),
     babl_component ("A"),
     NULL);
 
   babl_format_new (
-    "name",        "CIE Lab u8",
-    babl_model     ("CIE Lab"),
+    "name", "CIE Lab u8",
+    babl_model ("CIE Lab"),
 
-    babl_type      ("CIE u8 L"),
+    babl_type ("CIE u8 L"),
     babl_component ("CIE L"),
-    babl_type      ("CIE u8 ab"),
-    babl_component ("CIE a"), 
-    babl_type      ("CIE u8 ab"),
+    babl_type ("CIE u8 ab"),
+    babl_component ("CIE a"),
+    babl_type ("CIE u8 ab"),
     babl_component ("CIE b"),
     NULL);
 
   babl_format_new (
-    "name",        "CIE Lab u16",
-    babl_model     ("CIE Lab"),
+    "name", "CIE Lab u16",
+    babl_model ("CIE Lab"),
 
-    babl_type      ("CIE u16 L"),
+    babl_type ("CIE u16 L"),
     babl_component ("CIE L"),
-    babl_type      ("CIE u16 ab"),
-    babl_component ("CIE a"), 
-    babl_type      ("CIE u16 ab"),
+    babl_type ("CIE u16 ab"),
+    babl_component ("CIE a"),
+    babl_type ("CIE u16 ab"),
     babl_component ("CIE b"),
     NULL);
 }
@@ -345,7 +344,7 @@ convert_double_u8_scaled (double        min_val,
 {
   while (n--)
     {
-      double         dval = *(double *) src;
+      double        dval = *(double *) src;
       unsigned char u8val;
 
       if (dval < min_val)
@@ -353,11 +352,11 @@ convert_double_u8_scaled (double        min_val,
       else if (dval > max_val)
         u8val = max;
       else
-        u8val = rint ((dval-min_val) / (max_val-min_val) * (max-min) + min);
+        u8val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min);
 
       *(unsigned char *) dst = u8val;
-      src += src_pitch;
-      dst += dst_pitch;
+      src                   += src_pitch;
+      dst                   += dst_pitch;
     }
   return n;
 }
@@ -383,7 +382,7 @@ convert_u8_double_scaled (double        min_val,
       else if (u8val > max)
         dval = max_val;
       else
-        dval  = (u8val-min) / (double)(max-min) * (max_val-min_val) + min_val;
+        dval = (u8val - min) / (double) (max - min) * (max_val - min_val) + min_val;
 
       (*(double *) dst) = dval;
 
@@ -394,30 +393,30 @@ convert_u8_double_scaled (double        min_val,
 }
 
 #define MAKE_CONVERSIONS(name, min_val, max_val, min, max)      \
-static long                                                     \
-convert_##name##_double (char *src,                             \
-                         char *dst,                             \
-                         int   src_pitch,                       \
-                         int   dst_pitch,                       \
-                         long  n)                               \
-{                                                               \
-  return convert_u8_double_scaled (min_val, max_val, min, max,  \
-                            src, dst, src_pitch, dst_pitch, n); \
-}                                                               \
-static long                                                     \
-convert_double_##name (char *src,                               \
-                       char *dst,                               \
-                       int   src_pitch,                         \
-                       int   dst_pitch,                         \
-                       long  n)                                 \
-{                                                               \
-  return convert_double_u8_scaled (min_val, max_val, min, max,  \
-                            src, dst, src_pitch, dst_pitch, n); \
-}
+  static long \
+  convert_ ## name ## _double (char *src, \
+                               char *dst, \
+                               int src_pitch, \
+                               int dst_pitch, \
+                               long n)                               \
+  { \
+    return convert_u8_double_scaled (min_val, max_val, min, max, \
+                                     src, dst, src_pitch, dst_pitch, n); \
+  }                                                               \
+  static long \
+  convert_double_ ## name (char *src, \
+                           char *dst, \
+                           int src_pitch, \
+                           int dst_pitch, \
+                           long n)                                 \
+  { \
+    return convert_double_u8_scaled (min_val, max_val, min, max, \
+                                     src, dst, src_pitch, dst_pitch, n); \
+  }
 
 /* source ICC.1:2004-10 */
 
-MAKE_CONVERSIONS (u8_l,  0.0, 100.0,    0x00, 0xff);
+MAKE_CONVERSIONS (u8_l, 0.0, 100.0, 0x00, 0xff);
 MAKE_CONVERSIONS (u8_ab, -128.0, 127.0, 0x00, 0xff);
 
 #undef MAKE_CONVERSIONS
@@ -429,9 +428,9 @@ types_u8 (void)
     "CIE u8 L",
     "integer",
     "unsigned",
-    "bits",         8,
-    "min_val",    0.0,
-    "max_val",  100.0,
+    "bits", 8,
+    "min_val", 0.0,
+    "max_val", 100.0,
     NULL
   );
 
@@ -439,35 +438,35 @@ types_u8 (void)
     "CIE u8 ab",
     "integer",
     "unsigned",
-    "bits",         8,
-    "min_val",  -50.0,
-    "max_val",   50.0,
+    "bits", 8,
+    "min_val", -50.0,
+    "max_val", 50.0,
     NULL
   );
 
   babl_conversion_new (
     babl_type ("CIE u8 L"),
     babl_type ("double"),
-    "plane",      convert_u8_l_double,
+    "plane", convert_u8_l_double,
     NULL
   );
   babl_conversion_new (
     babl_type ("double"),
     babl_type ("CIE u8 L"),
-    "plane",      convert_double_u8_l,
+    "plane", convert_double_u8_l,
     NULL
   );
 
   babl_conversion_new (
     babl_type ("CIE u8 ab"),
     babl_type ("double"),
-    "plane",      convert_u8_ab_double,
+    "plane", convert_u8_ab_double,
     NULL
   );
   babl_conversion_new (
     babl_type ("double"),
     babl_type ("CIE u8 ab"),
-    "plane",      convert_double_u8_ab,
+    "plane", convert_double_u8_ab,
     NULL
   );
 }
@@ -493,11 +492,11 @@ convert_double_u16_scaled (double         min_val,
       else if (dval > max_val)
         u16val = max;
       else
-        u16val = rint ((dval-min_val) / (max_val-min_val) * (max-min) + min);
+        u16val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min);
 
       *(unsigned short *) dst = u16val;
-      dst += dst_pitch;
-      src += src_pitch;
+      dst                    += dst_pitch;
+      src                    += src_pitch;
     }
   return n;
 }
@@ -515,7 +514,7 @@ convert_u16_double_scaled (double         min_val,
 {
   while (n--)
     {
-      int    u16val = *(unsigned short*) src;
+      int    u16val = *(unsigned short *) src;
       double dval;
 
       if (u16val < min)
@@ -523,38 +522,38 @@ convert_u16_double_scaled (double         min_val,
       else if (u16val > max)
         dval = max_val;
       else
-        dval  = (u16val-min) / (double)(max-min) * (max_val-min_val) + min_val;
+        dval = (u16val - min) / (double) (max - min) * (max_val - min_val) + min_val;
 
       (*(double *) dst) = dval;
-      dst += dst_pitch;
-      src += src_pitch;
+      dst              += dst_pitch;
+      src              += src_pitch;
     }
   return n;
 }
 
 #define MAKE_CONVERSIONS(name, min_val, max_val, min, max)      \
-static long                                                     \
-convert_##name##_double (char *src,                             \
-                         char *dst,                             \
-                         int   src_pitch,                       \
-                         int   dst_pitch,                       \
-                         long  n)                               \
-{                                                               \
-  return convert_u16_double_scaled (min_val, max_val, min, max, \
-                             src, dst, src_pitch, dst_pitch, n);\
-}                                                               \
-static long                                                     \
-convert_double_##name (char *src,                               \
-                       char *dst,                               \
-                       int   src_pitch,                         \
-                       int   dst_pitch,                         \
-                       long  n)                                 \
-{                                                               \
-  return convert_double_u16_scaled (min_val, max_val, min, max, \
-                             src, dst, src_pitch, dst_pitch, n);\
-}
+  static long \
+  convert_ ## name ## _double (char *src, \
+                               char *dst, \
+                               int src_pitch, \
+                               int dst_pitch, \
+                               long n)                               \
+  { \
+    return convert_u16_double_scaled (min_val, max_val, min, max, \
+                                      src, dst, src_pitch, dst_pitch, n); \
+  }                                                               \
+  static long \
+  convert_double_ ## name (char *src, \
+                           char *dst, \
+                           int src_pitch, \
+                           int dst_pitch, \
+                           long n)                                 \
+  { \
+    return convert_double_u16_scaled (min_val, max_val, min, max, \
+                                      src, dst, src_pitch, dst_pitch, n); \
+  }
 
-MAKE_CONVERSIONS (u16_l,    0.0,  100.0, 0x00, 0xffff);
+MAKE_CONVERSIONS (u16_l, 0.0, 100.0, 0x00, 0xffff);
 MAKE_CONVERSIONS (u16_ab, -128.0, 127.0, 0x00, 0xffff);
 
 #undef MAKE_CONVERSIONS
@@ -562,25 +561,24 @@ MAKE_CONVERSIONS (u16_ab, -128.0, 127.0, 0x00, 0xffff);
 static void
 types_u16 (void)
 {
-
   babl_type_new (
     "CIE u16 L",
     "integer",
     "unsigned",
-    "bits",        16,
-    "min_val",    0.0,
-    "max_val",  100.0,
+    "bits", 16,
+    "min_val", 0.0,
+    "max_val", 100.0,
     NULL
   );
 
   babl_type_new (
     "CIE u16 ab",
-    "id",       "CIE u8 ab",
+    "id", "CIE u8 ab",
     "integer",
     "unsigned",
-    "bits",        16,
-    "min_val",  -50.0,
-    "max_val",   50.0,
+    "bits", 16,
+    "min_val", -50.0,
+    "max_val", 50.0,
     NULL
   );
 
@@ -588,26 +586,26 @@ types_u16 (void)
   babl_conversion_new (
     babl_type ("CIE u16 L"),
     babl_type ("double"),
-    "plane",      convert_u16_l_double,
+    "plane", convert_u16_l_double,
     NULL
   );
   babl_conversion_new (
     babl_type ("double"),
     babl_type ("CIE u16 L"),
-    "plane",      convert_double_u16_l,
+    "plane", convert_double_u16_l,
     NULL
   );
 
   babl_conversion_new (
     babl_type ("CIE u16 ab"),
     babl_type ("double"),
-    "plane",      convert_u16_ab_double,
+    "plane", convert_u16_ab_double,
     NULL
   );
   babl_conversion_new (
     babl_type ("double"),
     babl_type ("CIE u16 ab"),
-    "plane",      convert_double_u16_ab,
+    "plane", convert_double_u16_ab,
     NULL
   );
 }
@@ -622,75 +620,75 @@ types (void)
 
 
 
-/***********   cpercep.c *********   */ 
+/***********   cpercep.c *********   */
 
 
 /*
-Copyright (C) 1999-2002 Adam D. Moss (the "Author").  All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is fur-
-nished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
-NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
-NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the Author of the
-Software shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in this Software without prior written authorization
-from the Author.
-*/
+   Copyright (C) 1999-2002 Adam D. Moss (the "Author").  All Rights Reserved.
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is fur-
+   nished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+   NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+   AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+   NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+   Except as contained in this notice, the name of the Author of the
+   Software shall not be used in advertising or otherwise to promote the sale,
+   use or other dealings in this Software without prior written authorization
+   from the Author.
+ */
 
 /*
-  cpercep.c: The CPercep Functions v0.9: 2002-02-10
-  Adam D. Moss: adam@gimp.org <http://www.foxbox.org/adam/code/cpercep/>
-
-  This code module concerns itself with conversion from a hard-coded
-  RGB colour space (sRGB by default) to CIE L*a*b* and back again with
-  (primarily) precision and (secondarily) speed, oriented largely
-  towards the purposes of quantifying the PERCEPTUAL difference between
-  two arbitrary RGB colours with a minimum of fuss.
-
-  Motivation One: The author is disheartened at the amount of graphics
-  processing software around which uses weighted or non-weighted
-  Euclidean distance between co-ordinates within a (poorly-defined) RGB
-  space as the basis of what should really be an estimate of perceptual
-  difference to the human eye.  Certainly it's fast to do it that way,
-  but please think carefully about whether your particular application
-  should be tolerating sloppy results for the sake of real-time response.
-
-  Motivation Two: Lack of tested, re-usable and free code available
-  for this purpose.  The difficulty in finding something similar to
-  CPercep with a free license motivated this project; I hope that this
-  code also serves to illustrate how to perform the
-  R'G'B'->XYZ->L*a*b*->XYZ->R'G'B' transformation correctly since I
-  was distressed to note how many of the equations and code snippets
-  on the net were omitting the reverse transform and/or were using
-  incorrectly-derived or just plain wrong constants.
-
-  TODO: document functions, rename erroneously-named arguments
-*/
+   cpercep.c: The CPercep Functions v0.9: 2002-02-10
+   Adam D. Moss: adam@gimp.org <http://www.foxbox.org/adam/code/cpercep/>
+
+   This code module concerns itself with conversion from a hard-coded
+   RGB colour space (sRGB by default) to CIE L*a*b* and back again with
+   (primarily) precision and (secondarily) speed, oriented largely
+   towards the purposes of quantifying the PERCEPTUAL difference between
+   two arbitrary RGB colours with a minimum of fuss.
+
+   Motivation One: The author is disheartened at the amount of graphics
+   processing software around which uses weighted or non-weighted
+   Euclidean distance between co-ordinates within a (poorly-defined) RGB
+   space as the basis of what should really be an estimate of perceptual
+   difference to the human eye.  Certainly it's fast to do it that way,
+   but please think carefully about whether your particular application
+   should be tolerating sloppy results for the sake of real-time response.
+
+   Motivation Two: Lack of tested, re-usable and free code available
+   for this purpose.  The difficulty in finding something similar to
+   CPercep with a free license motivated this project; I hope that this
+   code also serves to illustrate how to perform the
+   R'G'B'->XYZ->L*a*b*->XYZ->R'G'B' transformation correctly since I
+   was distressed to note how many of the equations and code snippets
+   on the net were omitting the reverse transform and/or were using
+   incorrectly-derived or just plain wrong constants.
+
+   TODO: document functions, rename erroneously-named arguments
+ */
 
 /* defines added to make it compile outside gimp */
 
 #ifndef gboolean
-#define gboolean int
+#define gboolean    int
 #endif
 #ifndef FALSE
-#define FALSE    0
+#define FALSE       0
 #endif
 #ifndef TRUE
-#define TRUE     1
+#define TRUE        1
 #endif
 
 
@@ -699,7 +697,7 @@ from the Author.
 
 #ifndef __GLIBC__
 /* cbrt() is a GNU extension */
-#define cbrt(x) (pow(x, 1.0/3.0))
+#define cbrt(x)    (pow (x, 1.0 / 3.0))
 #endif
 
 /* #include "cpercep.h" */
@@ -718,7 +716,7 @@ from the Author.
    destined for an sRGB-alike display device (a typical modern monitor)
    -- if you change this then you'll probably want to change ASSUMED_GAMMA,
    the phosphor colours and the white point definition.
-*/
+ */
 
 /* #define SANITY */
 /* #define APPROX */
@@ -726,13 +724,13 @@ from the Author.
 
 
 #ifdef SRGB
-#define ASSUMED_GAMMA (2.2F)
+#define ASSUMED_GAMMA    (2.2F)
 #else
 /*#define ASSUMED_GAMMA (2.591F)*/
-#define ASSUMED_GAMMA (1.0F)
+#define ASSUMED_GAMMA    (1.0F)
 #endif
 
-#define REV_GAMMA ((1.0F / ASSUMED_GAMMA))
+#define REV_GAMMA        ((1.0F / ASSUMED_GAMMA))
 
 
 /* define characteristics of the source RGB space (and the space
@@ -792,30 +790,30 @@ static double powtable[256];
 
 
 #ifndef CLAMP
-#define CLAMP(x,l,u) ((x)<(l)?(l):((x)>(u)?(u):(x)))
+#define CLAMP(x, l, u)    ((x) < (l) ? (l) : ((x) > (u) ? (u) : (x)))
 #endif
 
 
 static void
-init_powtable(const double gamma)
+init_powtable (const double gamma)
 {
   int i;
 
 #ifndef SRGB
   /* pure gamma function */
-  for (i=0; i<256; i++)
+  for (i = 0; i < 256; i++)
     {
-      powtable[i] = pow((i)/255.0F, gamma);
+      powtable[i] = pow ((i) / 255.0F, gamma);
     }
 #else
   /* sRGB gamma curve */
-  for (i=0; i<11 /* 0.03928 * 255 */; i++)
+  for (i = 0; i < 11 /* 0.03928 * 255 */; i++)
     {
       powtable[i] = (i) / (255.0F * 12.92F);
     }
-  for (; i<256; i++)
+  for (; i < 256; i++)
     {
-      powtable[i] = pow(((i) / 255.0F) + 0.055F) / 1.055F, 2.4F);
+      powtable[i] = pow ((((i) / 255.0F) + 0.055F) / 1.055F, 2.4F);
     }
 #endif
 }
@@ -869,7 +867,7 @@ Minvert (CMatrix src, CMatrix dest)
 
 
 static void
-rgbxyzrgb_init(void)
+rgbxyzrgb_init (void)
 {
   init_powtable (ASSUMED_GAMMA);
 
@@ -879,7 +877,7 @@ rgbxyzrgb_init(void)
 
   {
     CMatrix MRC, MRCi;
-    double C1,C2,C3;
+    double  C1, C2, C3;
 
     MRC[0][0] = pxr;
     MRC[0][1] = pxg;
@@ -893,9 +891,9 @@ rgbxyzrgb_init(void)
 
     Minvert (MRC, MRCi);
 
-    C1 = MRCi[0][0]*xnn + MRCi[0][1] + MRCi[0][2]*znn;
-    C2 = MRCi[1][0]*xnn + MRCi[1][1] + MRCi[1][2]*znn;
-    C3 = MRCi[2][0]*xnn + MRCi[2][1] + MRCi[2][2]*znn;
+    C1 = MRCi[0][0] * xnn + MRCi[0][1] + MRCi[0][2] * znn;
+    C2 = MRCi[1][0] * xnn + MRCi[1][1] + MRCi[1][2] * znn;
+    C3 = MRCi[2][0] * xnn + MRCi[2][1] + MRCi[2][2] * znn;
 
     Mrgb_to_xyz[0][0] = MRC[0][0] * C1;
     Mrgb_to_xyz[0][1] = MRC[0][1] * C2;
@@ -914,50 +912,50 @@ rgbxyzrgb_init(void)
 
 static void
 xyz_to_rgb (double *inx_outr,
-           double *iny_outg,
-           double *inz_outb)
+            double *iny_outg,
+            double *inz_outb)
 {
   const double x = *inx_outr;
   const double y = *iny_outg;
   const double z = *inz_outb;
 
-  *inx_outr = Mxyz_to_rgb[0][0]*x + Mxyz_to_rgb[0][1]*y + Mxyz_to_rgb[0][2]*z;
-  *iny_outg = Mxyz_to_rgb[1][0]*x + Mxyz_to_rgb[1][1]*y + Mxyz_to_rgb[1][2]*z;
-  *inz_outb = Mxyz_to_rgb[2][0]*x + Mxyz_to_rgb[2][1]*y + Mxyz_to_rgb[2][2]*z;
+  *inx_outr = Mxyz_to_rgb[0][0] * x + Mxyz_to_rgb[0][1] * y + Mxyz_to_rgb[0][2] * z;
+  *iny_outg = Mxyz_to_rgb[1][0] * x + Mxyz_to_rgb[1][1] * y + Mxyz_to_rgb[1][2] * z;
+  *inz_outb = Mxyz_to_rgb[2][0] * x + Mxyz_to_rgb[2][1] * y + Mxyz_to_rgb[2][2] * z;
 }
 
 
 static void
 rgb_to_xyz (double *inr_outx,
-           double *ing_outy,
-           double *inb_outz)
+            double *ing_outy,
+            double *inb_outz)
 {
   const double r = *inr_outx;
   const double g = *ing_outy;
   const double b = *inb_outz;
 
-  *inr_outx = Mrgb_to_xyz[0][0]*r + Mrgb_to_xyz[0][1]*g + Mrgb_to_xyz[0][2]*b;
-  *ing_outy = Mrgb_to_xyz[1][0]*r + Mrgb_to_xyz[1][1]*g + Mrgb_to_xyz[1][2]*b;
-  *inb_outz = Mrgb_to_xyz[2][0]*r + Mrgb_to_xyz[2][1]*g + Mrgb_to_xyz[2][2]*b;
+  *inr_outx = Mrgb_to_xyz[0][0] * r + Mrgb_to_xyz[0][1] * g + Mrgb_to_xyz[0][2] * b;
+  *ing_outy = Mrgb_to_xyz[1][0] * r + Mrgb_to_xyz[1][1] * g + Mrgb_to_xyz[1][2] * b;
+  *inb_outz = Mrgb_to_xyz[2][0] * r + Mrgb_to_xyz[2][1] * g + Mrgb_to_xyz[2][2] * b;
 }
 
 
 static inline double
-ffunc(const double t)
+ffunc (const double t)
 {
   if (t > 0.008856F)
     {
-      return (cbrt(t));
+      return (cbrt (t));
     }
   else
     {
-      return (7.787F * t + 16.0F/116.0F);
+      return (7.787F * t + 16.0F / 116.0F);
     }
 }
 
 
 static inline double
-ffunc_inv(const double t)
+ffunc_inv (const double t)
 {
   if (t > 0.206893F)
     {
@@ -965,18 +963,18 @@ ffunc_inv(const double t)
     }
   else
     {
-      return ((t - 16.0F/116.0F) / 7.787F);
+      return ((t - 16.0F / 116.0F) / 7.787F);
     }
 }
 
 
 static void
 xyz_to_lab (double *inx,
-           double *iny,
-           double *inz)
+            double *iny,
+            double *inz)
 {
-  double L,a,b;
-  double ffuncY;
+  double       L, a, b;
+  double       ffuncY;
   const double X = *inx;
   const double Y = *iny;
   const double Z = *inz;
@@ -984,24 +982,24 @@ xyz_to_lab (double *inx,
   if (Y > 0.0F)
     {
       if (Y > 0.008856F)
-       {
-         L = (116.0F * cbrt(Y)) - 16.0F;
-       }
+        {
+          L = (116.0F * cbrt (Y)) - 16.0F;
+        }
       else
-       {
-         L = (Y * 903.3F);
-       }
+        {
+          L = (Y * 903.3F);
+        }
 
 #ifdef SANITY
       if (L < 0.0F)
-       {
-         g_printerr (" <eek1>%f \007",(float)L);
-       }
+        {
+          g_printerr (" <eek1>%f \007", (float) L);
+        }
 
       if (L > 100.0F)
-       {
-         g_printerr (" <eek2>%f \007",(float)L);
-       }
+        {
+          g_printerr (" <eek2>%f \007", (float) L);
+        }
 #endif
     }
   else
@@ -1009,9 +1007,9 @@ xyz_to_lab (double *inx,
       L = 0.0;
     }
 
-  ffuncY = ffunc(Y);
-  a = 500.0F * (ffunc(X/xnn) - ffuncY);
-  b = 200.0F * (ffuncY - ffunc(Z/znn));
+  ffuncY = ffunc (Y);
+  a      = 500.0F * (ffunc (X / xnn) - ffuncY);
+  b      = 200.0F * (ffuncY - ffunc (Z / znn));
 
   *inx = L;
   *iny = a;
@@ -1021,11 +1019,11 @@ xyz_to_lab (double *inx,
 
 static void
 lab_to_xyz (double *inl,
-           double *ina,
-           double *inb)
+            double *ina,
+            double *inb)
 {
-  double X,Y,Z;
-  double P;
+  double       X, Y, Z;
+  double       P;
   const double L = *inl;
   const double a = *ina;
   const double b = *inb;
@@ -1038,31 +1036,31 @@ lab_to_xyz (double *inl,
   else
     {
       Y = L / 903.3F;
-      P = 7.787F * Y + 16.0F/116.0F;
+      P = 7.787F * Y + 16.0F / 116.0F;
     }
 
   X = (P + a / 500.0F);
-  X = xnn * ffunc_inv(X);
+  X = xnn *ffunc_inv (X);
   Z = (P - b / 200.0F);
-  Z = znn * ffunc_inv(Z);
+  Z = znn *ffunc_inv (Z);
 
 #ifdef SANITY
-  if (X<-0.00000F)
+  if (X < -0.00000F)
     {
-      if (X<-0.0001F)
-       g_printerr ("{badX %f {%f,%f,%f}}",X,L,a,b);
+      if (X < -0.0001F)
+        g_printerr ("{badX %f {%f,%f,%f}}", X, L, a, b);
       X = 0.0F;
     }
-  if (Y<-0.00000F)
+  if (Y < -0.00000F)
     {
-      if (Y<-0.0001F)
-       g_printerr ("{badY %f}",Y);
+      if (Y < -0.0001F)
+        g_printerr ("{badY %f}", Y);
       Y = 0.0F;
     }
-  if (Z<-0.00000F)
+  if (Z < -0.00000F)
     {
-      if (Z<-0.1F)
-       g_printerr ("{badZ %f}",Z);
+      if (Z < -0.1F)
+        g_printerr ("{badZ %f}", Z);
       Z = 0.0F;
     }
 #endif
@@ -1080,9 +1078,9 @@ cpercep_init (void)
 {
   static gboolean initialized = FALSE;
 
-  if (! initialized)
+  if (!initialized)
     {
-      rgbxyzrgb_init();
+      rgbxyzrgb_init ();
       initialized = TRUE;
     }
 }
@@ -1091,7 +1089,7 @@ void
 cpercep_rgb_to_space (double  inr,
                       double  ing,
                       double  inb,
-                     double *outr,
+                      double *outr,
                       double *outg,
                       double *outb)
 {
@@ -1104,37 +1102,37 @@ cpercep_rgb_to_space (double  inr,
       (inr) < -0.0F ||
       (ing) < -0.0F ||
       (inb) < -0.0F
-      )
-    abort();
+  )
+    abort ();
 #endif /* SANITY */
-  inr = powtable[(int)inr];
-  ing = powtable[(int)ing];
-  inb = powtable[(int)inb];
+  inr = powtable[(int) inr];
+  ing = powtable[(int) ing];
+  inb = powtable[(int) inb];
 #else
 #ifdef SRGB
   /* sRGB gamma curve */
   if (inr <= (0.03928F * 255.0F))
-      inr = inr / (255.0F * 12.92F);
+    inr = inr / (255.0F * 12.92F);
   else
-      inr = pow( (inr + (0.055F * 255.0F)) / (1.055F * 255.0F), 2.4F);
+    inr = pow ((inr + (0.055F * 255.0F)) / (1.055F * 255.0F), 2.4F);
 
   if (ing <= (0.03928F * 255.0F))
-      ing = ing / (255.0F * 12.92F);
+    ing = ing / (255.0F * 12.92F);
   else
-      ing = pow( (ing + (0.055F * 255.0F)) / (1.055F * 255.0F), 2.4F);
+    ing = pow ((ing + (0.055F * 255.0F)) / (1.055F * 255.0F), 2.4F);
 
   if (inb <= (0.03928F * 255.0F))
-      inb = inb / (255.0F * 12.92F);
+    inb = inb / (255.0F * 12.92F);
   else
-      inb = pow( (inb + (0.055F * 255.0F)) / (1.055F * 255.0F), 2.4F);
+    inb = pow ((inb + (0.055F * 255.0F)) / (1.055F * 255.0F), 2.4F);
 #else
   /* pure gamma function */
 
   /*  babl uses normalized RGB
-  inr = pow((inr)/255.0F, ASSUMED_GAMMA);
-  ing = pow((ing)/255.0F, ASSUMED_GAMMA);
-  inb = pow((inb)/255.0F, ASSUMED_GAMMA);
-  */
+     inr = pow((inr)/255.0F, ASSUMED_GAMMA);
+     ing = pow((ing)/255.0F, ASSUMED_GAMMA);
+     inb = pow((inb)/255.0F, ASSUMED_GAMMA);
+   */
 #endif /* SRGB */
 #endif /* APPROX */
 
@@ -1146,24 +1144,24 @@ cpercep_rgb_to_space (double  inr,
       (inr) < 0.0F ||
       (ing) < 0.0F ||
       (inb) < 0.0F
-      )
+  )
     {
       g_printerr ("%%");
       /* abort(); */
     }
 #endif /* SANITY */
 
-  rgb_to_xyz(&inr, &ing, &inb);
+  rgb_to_xyz (&inr, &ing, &inb);
 
 #ifdef SANITY
   if (inr < 0.0F || ing < 0.0F || inb < 0.0F)
     {
       g_printerr (" [BAD2 XYZ: %f,%f,%f]\007 ",
-             inr,ing,inb);
+                  inr, ing, inb);
     }
 #endif /* SANITY */
 
-  xyz_to_lab(&inr, &ing, &inb);
+  xyz_to_lab (&inr, &ing, &inb);
 
   *outr = inr;
   *outg = ing;
@@ -1175,48 +1173,48 @@ void
 cpercep_space_to_rgb (double  inr,
                       double  ing,
                       double  inb,
-                     double *outr,
+                      double *outr,
                       double *outg,
                       double *outb)
 {
-  lab_to_xyz(&inr, &ing, &inb);
+  lab_to_xyz (&inr, &ing, &inb);
 
 #ifdef SANITY
-  if (inr<-0.0F || ing<-0.0F || inb<-0.0F)
+  if (inr < -0.0F || ing < -0.0F || inb < -0.0F)
     {
       g_printerr (" [BAD1 XYZ: %f,%f,%f]\007 ",
-             inr,ing,inb);
+                  inr, ing, inb);
     }
 #endif
 
-  xyz_to_rgb(&inr, &ing, &inb);
+  xyz_to_rgb (&inr, &ing, &inb);
 
   /* yes, essential.  :( */
-  inr = CLAMP(inr,0.0F,1.0F);
-  ing = CLAMP(ing,0.0F,1.0F);
-  inb = CLAMP(inb,0.0F,1.0F);
+  inr = CLAMP (inr, 0.0F, 1.0F);
+  ing = CLAMP (ing, 0.0F, 1.0F);
+  inb = CLAMP (inb, 0.0F, 1.0F);
 
 #ifdef SRGB
   if (inr <= 0.0030402477F)
     inr = inr * (12.92F * 255.0F);
   else
-    inr = pow(inr, 1.0F/2.4F) * (1.055F * 255.0F) - (0.055F * 255.0F);
+    inr = pow (inr, 1.0F / 2.4F) * (1.055F * 255.0F) - (0.055F * 255.0F);
 
   if (ing <= 0.0030402477F)
     ing = ing * (12.92F * 255.0F);
   else
-    ing = pow(ing, 1.0F/2.4F) * (1.055F * 255.0F) - (0.055F * 255.0F);
+    ing = pow (ing, 1.0F / 2.4F) * (1.055F * 255.0F) - (0.055F * 255.0F);
 
   if (inb <= 0.0030402477F)
     inb = inb * (12.92F * 255.0F);
   else
-    inb = pow(inb, 1.0F/2.4F) * (1.055F * 255.0F) - (0.055F * 255.0F);
+    inb = pow (inb, 1.0F / 2.4F) * (1.055F * 255.0F) - (0.055F * 255.0F);
 #else
   /* babl uses normalized RGB values
-  inr = 255.0F * pow(inr, REV_GAMMA);
-  ing = 255.0F * pow(ing, REV_GAMMA);
-  inb = 255.0F * pow(inb, REV_GAMMA);
-  */
+     inr = 255.0F * pow(inr, REV_GAMMA);
+     ing = 255.0F * pow(ing, REV_GAMMA);
+     inb = 255.0F * pow(inb, REV_GAMMA);
+   */
 #endif
 
   *outr = inr;
@@ -1229,18 +1227,18 @@ cpercep_space_to_rgb (double  inr,
 /* EXPERIMENTAL SECTION */
 
 const double
-xscaler(const double start, const double end,
-       const double me, const double him)
+xscaler (const double start, const double end,
+         const double me, const double him)
 {
-  return start + ((end-start) * him) / (me + him);
+  return start + ((end - start) * him) / (me + him);
 }
 
 
 void
 mix_colours (const double L1, const double a1, const double b1,
-            const double L2, const double a2, const double b2,
-            double *rtnL, double *rtna, double *rtnb,
-            double mass1, double mass2)
+             const double L2, const double a2, const double b2,
+             double *rtnL, double *rtna, double *rtnb,
+             double mass1, double mass2)
 {
   double w1, w2;
 
@@ -1249,13 +1247,12 @@ mix_colours (const double L1, const double a1, const double b1,
   *rtna = xscaler (a1, a2, mass1, mass2);
   *rtnb = xscaler (b1, b2, mass1, mass2);
 #else
-
 #if 1
   w1 = mass1 * L1;
   w2 = mass2 * L2;
 #else
-  w1 = mass1 * (L1*L1*L1);
-  w2 = mass2 * (L2*L2*L2);
+  w1 = mass1 * (L1 * L1 * L1);
+  w2 = mass2 * (L2 * L2 * L2);
 #endif
 
   *rtnL = xscaler (L1, L2, mass1, mass2);
@@ -1263,19 +1260,19 @@ mix_colours (const double L1, const double a1, const double b1,
   if (w1 <= 0.0 &&
       w2 <= 0.0)
     {
-      *rtna =
-       *rtnb = 0.0;
+      *rtna   =
+        *rtnb = 0.0;
 #ifdef SANITY
       /* g_printerr ("\007OUCH. "); */
 #endif
     }
   else
     {
-      *rtna = xscaler(a1, a2, w1, w2);
-      *rtnb = xscaler(b1, b2, w1, w2);
+      *rtna = xscaler (a1, a2, w1, w2);
+      *rtnb = xscaler (b1, b2, w1, w2);
     }
 #endif
 }
 #endif /* EXPERIMENTAL SECTION */
 
-/***********  /cpercep.c *********   */ 
+/***********  /cpercep.c *********   */
index 91afb9cbe3daf3a65d8e5b6fa85d58b0d6b7e0a3..8fceaa60fd1efc5c883a4d2c6420ad00aac39db9 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "babl.h"
 
-#define INLINE inline
+#define INLINE    inline
 
 #include <math.h>
 #include <stdio.h>
@@ -41,7 +41,7 @@
  *
  * due to ability to be able to relicence gggl under a different
  * licence than GPL, I avoided the temptation to look at the
- * source files in the same location, in case I was going to 
+ * source files in the same location, in case I was going to
  * need this piece of code for projects where GPL compatibility
  * was a must.
  *
@@ -56,7 +56,7 @@ static inline double
 linear_to_gamma_2_2 (double value)
 {
   if (value > 0.0030402477F)
-    return 1.055F * pow (value, (1.0F/2.4F)) - 0.055F;
+    return 1.055F *pow (value, (1.0F / 2.4F)) - 0.055F;
   return 12.92F * value;
 }
 
@@ -70,19 +70,19 @@ gamma_2_2_to_linear (double value)
 
 
 #else
-  #define linear_to_gamma_2_2(value) (pow((value), (1.0F/2.2F)))
-  #define gamma_2_2_to_linear(value) (pow((value), 2.2F))
+  #define linear_to_gamma_2_2(value)    (pow ((value), (1.0F / 2.2F)))
+  #define gamma_2_2_to_linear(value)    (pow ((value), 2.2F))
 #endif
 
 
 /* lookup tables used in conversion */
 
-static float table_8_F[1 << 8];
-static float table_8g_F[1 << 8];
+static float         table_8_F[1 << 8];
+static float         table_8g_F[1 << 8];
 static unsigned char table_F_8[1 << 16];
 static unsigned char table_F_8g[1 << 16];
 
-static int table_inited = 0;
+static int           table_inited = 0;
 
 static void
 table_init (void)
@@ -93,19 +93,19 @@ table_init (void)
 
   /* fill tables for conversion from integer to float */
   {
-    int       i;
+    int i;
     for (i = 0; i < 1 << 8; i++)
       {
-        float direct = i/255.0;
-        table_8_F[i] = direct;
-        table_8g_F[i] = gamma_2_2_to_linear(direct);
+        float direct = i / 255.0;
+        table_8_F[i]  = direct;
+        table_8g_F[i] = gamma_2_2_to_linear (direct);
       }
   }
   /* fill tables for conversion from float to integer */
   {
     union
     {
-      float     f;
+      float          f;
       unsigned short s[2];
     } u;
     u.f = 0.0;
@@ -119,34 +119,34 @@ table_init (void)
 
         if (u.f <= 0.0)
           {
-            c = 0;
+            c  = 0;
             cg = 0;
           }
         else if (u.f >= 1.0)
           {
-            c = 255;
+            c  = 255;
             cg = 255;
           }
         else
           {
             c  = rint (u.f * 255.0);
-            cg = rint (linear_to_gamma_2_2(u.f) * 255.0);
+            cg = rint (linear_to_gamma_2_2 (u.f) * 255.0);
           }
 
-        table_F_8[u.s[1]] = c;
+        table_F_8[u.s[1]]  = c;
         table_F_8g[u.s[1]] = cg;
       }
   }
   /* fix tables to ensure 1:1 conversions back and forth */
   if (0)
     {
-      int       i;
+      int i;
       for (i = 0; i < 256; i++)
         {
-          float     f = table_8_F[i];
-          unsigned short *hi = ((unsigned short *)(void*) &f);
-          unsigned short *lo = ((unsigned short *)(void*) &f);
-          *lo = 0;
+          float           f  = table_8_F[i];
+          unsigned short *hi = ((unsigned short *) (void *) &f);
+          unsigned short *lo = ((unsigned short *) (void *) &f);
+          *lo              = 0;
           table_F_8[(*hi)] = i;
         }
     }
@@ -158,7 +158,7 @@ gggl_float_to_index16 (float f)
 {
   union
   {
-    float     f;
+    float          f;
     unsigned short s[2];
   } u;
   u.f = f;
@@ -168,15 +168,16 @@ gggl_float_to_index16 (float f)
 static INLINE long
 conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       register float f = (*(float *) src);
       *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      dst += 1;
-      src += 4;
+      dst                   += 1;
+      src                   += 4;
     }
   return samples;
 }
@@ -185,15 +186,16 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_8g (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       register float f = (*(float *) src);
       *(unsigned char *) dst = table_F_8g[gggl_float_to_index16 (f)];
-      dst += 1;
-      src += 4;
+      dst                   += 1;
+      src                   += 4;
     }
   return samples;
 }
@@ -202,14 +204,15 @@ conv_F_8g (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       (*(float *) dst) = table_8_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
     }
   return samples;
 }
@@ -218,27 +221,27 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
-  {
+    {
       register float f = (*(float *) src);
       *(unsigned char *) dst = table_F_8g[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
-      f = (*(float *) src);
+      f                      = (*(float *) src);
       *(unsigned char *) dst = table_F_8g[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
-      f = (*(float *) src);
+      f                      = (*(float *) src);
       *(unsigned char *) dst = table_F_8g[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
       src += 4;
-
-  }
+    }
   return samples;
 }
 
@@ -246,33 +249,34 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
-  {
+    {
       register float f = (*(float *) src);
       *(unsigned char *) dst = table_F_8g[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
-      f = (*(float *) src);
+      f                      = (*(float *) src);
       *(unsigned char *) dst = table_F_8g[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
-      f = (*(float *) src);
+      f                      = (*(float *) src);
       *(unsigned char *) dst = table_F_8g[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
-      f = (*(float *) src);
+      f                      = (*(float *) src);
       *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
-  }
+      src                   += 4;
+      dst                   += 1;
+    }
   return samples;
 }
 
-#define conv_rgbaF_rgbP8 conv_rgbaF_rgba8
+#define conv_rgbaF_rgbP8    conv_rgbaF_rgba8
 
 static INLINE long
 conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
@@ -288,32 +292,33 @@ conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbAF_rgbA8 conv_rgbaF_rgba8
-#define conv_gF_g8       conv_F_8
-#define conv_gAF_gA8     conv_gaF_ga8
+#define conv_rgbAF_rgbA8    conv_rgbaF_rgba8
+#define conv_gF_g8          conv_F_8
+#define conv_gAF_gA8        conv_gaF_ga8
 
 
 static INLINE long
 conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(float *) dst) = table_8g_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
 
       (*(float *) dst) = table_8g_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
 
       (*(float *) dst) = table_8g_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
 
-      (*(float *) dst) = table_8_F[*(unsigned char*) src];
-      dst += 4;
-      src += 1;
+      (*(float *) dst) = table_8_F[*(unsigned char *) src];
+      dst             += 4;
+      src             += 1;
     }
   return samples;
 }
@@ -321,23 +326,24 @@ conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(float *) dst) = table_8g_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
 
       (*(float *) dst) = table_8g_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
 
       (*(float *) dst) = table_8g_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
 
       (*(float *) dst) = 1.0;
-      dst += 4;
+      dst             += 4;
     }
   return samples;
 }
@@ -347,37 +353,38 @@ conv_rgbAF_sdl32 (unsigned char *srcc,
                   unsigned char *dstc,
                   long           samples)
 {
-  float         *src = (void*)srcc;
-  unsigned char *dst = (void*)dstc;
-  long n=samples;
+  float         *src = (void *) srcc;
+  unsigned char *dst = (void *) dstc;
+  long           n   = samples;
+
   while (n--)
     {
-      int i;
+      int   i;
       float alpha = src[3];
       if (alpha < 0.0001)
         alpha = 0.0001;
-      for (i=0;i<3;i++)
+      for (i = 0; i < 3; i++)
         {
-          float ca=src[i];
+          float ca = src[i];
           float c;
-          int ret;
-          c=ca/alpha;
-          if (alpha==0.0)
-            ret=0;
+          int   ret;
+          c = ca / alpha;
+          if (alpha == 0.0)
+            ret = 0;
           else
             ret = table_F_8g[gggl_float_to_index16 (c)];
-          if (ret<=0)
-            dst[i]=0;
-          else if (ret>255)
-            dst[i]=255;
+          if (ret <= 0)
+            dst[i] = 0;
+          else if (ret > 255)
+            dst[i] = 255;
           else
             dst[i] = ret;
         }
       {
-        int t=dst[0];
-        dst[0]=dst[2];
-        dst[2]=t;
-        dst[3]=255;
+        int t = dst[0];
+        dst[0] = dst[2];
+        dst[2] = t;
+        dst[3] = 255;
       }
       src += 4;
       dst += 4;
@@ -391,16 +398,17 @@ conv_rgbaF_sdl32 (unsigned char *srcc,
                   unsigned char *dstc,
                   long           samples)
 {
-  float         *src = (void*)srcc;
-  unsigned char *dst = (void*)dstc;
-  long n=samples;
+  float         *src = (void *) srcc;
+  unsigned char *dst = (void *) dstc;
+  long           n   = samples;
+
   while (n--)
     {
       dst[0] = table_F_8g[gggl_float_to_index16 (src[2])];
       dst[1] = table_F_8g[gggl_float_to_index16 (src[1])];
       dst[2] = table_F_8g[gggl_float_to_index16 (src[0])];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -410,24 +418,25 @@ conv_rgbAF_rgb8 (unsigned char *srcc,
                  unsigned char *dstc,
                  long           samples)
 {
-  float         *src = (void*)srcc;
-  unsigned char *dst = (void*)dstc;
-  long n=samples;
+  float         *src = (void *) srcc;
+  unsigned char *dst = (void *) dstc;
+  long           n   = samples;
+
   while (n--)
     {
       float alpha = src[3];
       if (alpha < 0.00001)
         {
-          dst[0]=0;
-          dst[1]=0;
-          dst[2]=0;
+          dst[0] = 0;
+          dst[1] = 0;
+          dst[2] = 0;
         }
       else
         {
-          float alpha_recip = 1.0/alpha;
-          dst[0] = table_F_8g[gggl_float_to_index16 (src[0]*alpha_recip)];
-          dst[1] = table_F_8g[gggl_float_to_index16 (src[1]*alpha_recip)];
-          dst[2] = table_F_8g[gggl_float_to_index16 (src[2]*alpha_recip)];
+          float alpha_recip = 1.0 / alpha;
+          dst[0] = table_F_8g[gggl_float_to_index16 (src[0] * alpha_recip)];
+          dst[1] = table_F_8g[gggl_float_to_index16 (src[1] * alpha_recip)];
+          dst[2] = table_F_8g[gggl_float_to_index16 (src[2] * alpha_recip)];
         }
       src += 4;
       dst += 3;
@@ -440,24 +449,25 @@ conv_bgrA8_rgba8 (unsigned char *srcc,
                   unsigned char *dstc,
                   long           samples)
 {
-  unsigned char *src = (void*)srcc;
-  unsigned char *dst = (void*)dstc;
-  long n=samples;
+  unsigned char *src = (void *) srcc;
+  unsigned char *dst = (void *) dstc;
+  long           n   = samples;
+
   while (n--)
     {
-      unsigned char alpha=src[3];
-      dst[0]=alpha?(src[2]*255/alpha):0;
-      dst[1]=alpha?(src[1]*255/alpha):0;
-      dst[2]=alpha?(src[0]*255/alpha):0;
-      dst[3]=alpha;
-      src+=4;
-      dst+=4;
+      unsigned char alpha = src[3];
+      dst[0] = alpha ? (src[2] * 255 / alpha) : 0;
+      dst[1] = alpha ? (src[1] * 255 / alpha) : 0;
+      dst[2] = alpha ? (src[0] * 255 / alpha) : 0;
+      dst[3] = alpha;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
 
 
-#define conv_rgb8_rgbAF conv_rgb8_rgbaF
+#define conv_rgb8_rgbAF    conv_rgb8_rgbaF
 
 int init (void);
 
@@ -465,59 +475,59 @@ int
 init (void)
 {
   Babl *rgbaF = babl_format_new (
-      babl_model ("RGBA"),
-      babl_type  ("float"),
-      babl_component ("R"),
-      babl_component ("G"),
-      babl_component ("B"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RGBA"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbAF = babl_format_new (
-      babl_model ("RaGaBaA"),
-      babl_type  ("float"),
-      babl_component ("Ra"),
-      babl_component ("Ga"),
-      babl_component ("Ba"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RaGaBaA"),
+    babl_type ("float"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
   Babl *rgba8 = babl_format_new (
-      babl_model ("R'G'B'A"),
-      babl_type  ("u8"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("R'G'B'A"),
+    babl_type ("u8"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
   Babl *bgrA8 = babl_format_new (
-      "name", "B'aG'aR'aA u8",
-      babl_model ("R'aG'aB'aA"),
-      babl_type  ("u8"),
-      babl_component ("B'a"),
-      babl_component ("G'a"),
-      babl_component ("R'a"),
-      babl_component ("A"),
-      NULL);
+    "name", "B'aG'aR'aA u8",
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("u8"),
+    babl_component ("B'a"),
+    babl_component ("G'a"),
+    babl_component ("R'a"),
+    babl_component ("A"),
+    NULL);
   Babl *rgb8 = babl_format_new (
-      babl_model ("R'G'B'"),
-      babl_type  ("u8"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      NULL);
+    babl_model ("R'G'B'"),
+    babl_type ("u8"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
   Babl *sdl32 = babl_format_new (
-      "name", "B'aG'aR'aPAD u8",
-      babl_model ("R'G'B'"),
-      babl_type  ("u8"),
-      babl_component ("B'"),
-      babl_component ("G'"),
-      babl_component ("R'"),
-      babl_component ("PAD"),
-      NULL);
+    "name", "B'aG'aR'aPAD u8",
+    babl_model ("R'G'B'"),
+    babl_type ("u8"),
+    babl_component ("B'"),
+    babl_component ("G'"),
+    babl_component ("R'"),
+    babl_component ("PAD"),
+    NULL);
 
   table_init ();
 
-#define o(src,dst) \
-  babl_conversion_new (src, dst, "linear", conv_##src##_##dst, NULL)
+#define o(src, dst) \
+  babl_conversion_new (src, dst, "linear", conv_ ## src ## _ ## dst, NULL)
 
   o (rgb8, rgbaF);
   o (rgb8, rgbAF);
index e5398e6ed71ad2ce4cf8cb2c8ed63fe32cbd6b9a..9e4d395e09337ed22db32f116b0ca3cf77f2ff3b 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "babl.h"
 
-#define INLINE inline
+#define INLINE    inline
 
 #include <math.h>
 #include <stdio.h>
@@ -41,7 +41,7 @@
  *
  * due to ability to be able to relicence gggl under a different
  * licence than GPL, I avoided the temptation to look at the
- * source files in the same location, in case I was going to 
+ * source files in the same location, in case I was going to
  * need this piece of code for projects where GPL compatibility
  * was a must.
  *
@@ -54,9 +54,9 @@
 
 /* lookup tables used in conversion */
 
-static float table_8_F[1 << 8];
-static float table_16_F[1 << 16];
-static unsigned char table_F_8[1 << 16];
+static float          table_8_F[1 << 8];
+static float          table_16_F[1 << 16];
+static unsigned char  table_F_8[1 << 16];
 static unsigned short table_F_16[1 << 16];
 
 
@@ -71,7 +71,7 @@ table_init (void)
 
   /* fill tables for conversion from integer to float */
   {
-    int       i;
+    int i;
     for (i = 0; i < 1 << 8; i++)
       {
         table_8_F[i] = (i * 1.0) / 255.0;
@@ -83,7 +83,7 @@ table_init (void)
   {
     union
     {
-      float     f;
+      float          f;
       unsigned short s[2];
     } u;
     u.f = 0.0;
@@ -92,7 +92,7 @@ table_init (void)
 
     for (u.s[1] = 0; u.s[1] < 65535; u.s[1] += 1)
       {
-        unsigned char c;
+        unsigned char  c;
         unsigned short s;
 
         if (u.f <= 0.0)
@@ -115,20 +115,20 @@ table_init (void)
            / if (! ((*hi)%9))
            /         fprintf (stderr, "\n"); */
 
-        table_F_8[u.s[1]] = c;
+        table_F_8[u.s[1]]  = c;
         table_F_16[u.s[1]] = s;
       }
   }
   /* fix tables to ensure 1:1 conversions back and forth */
   if (0)
     {                           /*FIXME: probably not the right way to do it,.. must sit down and scribble on paper */
-      int       i;
+      int i;
       for (i = 0; i < 256; i++)
         {
-          float     f = table_8_F[i];
-          unsigned short *hi = ((unsigned short *) (void*)&f);
-          unsigned short *lo = ((unsigned short *) (void*)&f);
-          *lo = 0;
+          float           f  = table_8_F[i];
+          unsigned short *hi = ((unsigned short *) (void *) &f);
+          unsigned short *lo = ((unsigned short *) (void *) &f);
+          *lo              = 0;
           table_F_8[(*hi)] = i;
         }
     }
@@ -140,7 +140,7 @@ gggl_float_to_index16 (float f)
 {
   union
   {
-    float     f;
+    float          f;
     unsigned short s[2];
   } u;
   u.f = f;
@@ -151,15 +151,16 @@ gggl_float_to_index16 (float f)
 static INLINE long
 conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       register float f = (*(float *) src);
       *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      dst += 1;
-      src += 4;
+      dst                   += 1;
+      src                   += 4;
     }
   return samples;
 }
@@ -167,15 +168,16 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       register float f = (*(float *) src);
       *(unsigned short *) dst = table_F_16[gggl_float_to_index16 (f)];
-      dst += 2;
-      src += 4;
+      dst                    += 2;
+      src                    += 4;
     }
   return samples;
 }
@@ -183,14 +185,15 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       (*(float *) dst) = table_8_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
     }
   return samples;
 }
@@ -198,14 +201,15 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_16_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       (*(float *) dst) = table_16_F[*(unsigned short *) src];
-      dst += 4;
-      src += 2;
+      dst             += 4;
+      src             += 2;
     }
   return samples;
 }
@@ -215,10 +219,11 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     f = ((*(float *) src));
+      float f = ((*(float *) src));
       if (f < 0.0)
         {
           *(unsigned char *) dst = 0;
@@ -240,10 +245,11 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     f = ((*(float *) src));
+      float f = ((*(float *) src));
       if (f < 0.0)
         {
           *(unsigned short *) dst = 0;
@@ -267,12 +273,13 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(float *) dst) = (*(unsigned char *) src / 255.0);
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
     }
   return samples;
 }
@@ -280,12 +287,13 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_16_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(float *) dst) = *(unsigned short *) src / 65535.0;
-      dst += 4;
-      src += 2;
+      dst             += 4;
+      src             += 2;
     }
   return samples;
 }
@@ -296,12 +304,13 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_D (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(double *) dst = ((*(float *) src));
-      dst += 8;
-      src += 4;
+      dst            += 8;
+      src            += 4;
     }
   return samples;
 }
@@ -310,24 +319,26 @@ conv_F_D (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_D_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(float *) dst = ((*(double *) src));
-      dst += 4;
-      src += 8;
+      dst           += 4;
+      src           += 8;
     }
   return samples;
 }
 static INLINE long
 conv_16_8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(unsigned char *) dst) = (*(unsigned short *) src) >> 8;
-      dst += 1;
-      src += 2;
+      dst                     += 1;
+      src                     += 2;
     }
   return samples;
 }
@@ -335,12 +346,13 @@ conv_16_8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_8_16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(unsigned short *) dst) = (*(unsigned char *) src) << 8;
-      dst += 2;
-      src += 1;
+      dst                      += 2;
+      src                      += 1;
     }
   return samples;
 }
@@ -353,7 +365,7 @@ conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbaF_rgbP8 conv_rgbaF_rgba8
+#define conv_rgbaF_rgbP8    conv_rgbaF_rgba8
 
 static INLINE long
 conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
@@ -369,9 +381,9 @@ conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbAF_rgbA8 conv_rgbaF_rgba8
-#define conv_gF_g8       conv_F_8
-#define conv_gAF_gA8     conv_gaF_ga8
+#define conv_rgbAF_rgbA8    conv_rgbaF_rgba8
+#define conv_gF_g8          conv_F_8
+#define conv_gAF_gA8        conv_gaF_ga8
 
 static INLINE long
 conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples)
@@ -408,11 +420,11 @@ conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbAF_rgbAD  conv_rgbaF_rgbaD
-#define conv_rgbAD_rgbAD  conv_rgbaD_rgbaF
-#define conv_rgbAF_rgbA16 conv_rgbaF_rgba16
-#define conv_gF_g16       conv_F_16
-#define conv_gAF_gA16     conv_gaF_ga16
+#define conv_rgbAF_rgbAD     conv_rgbaF_rgbaD
+#define conv_rgbAD_rgbAD     conv_rgbaD_rgbaF
+#define conv_rgbAF_rgbA16    conv_rgbaF_rgba16
+#define conv_gF_g16          conv_F_16
+#define conv_gAF_gA16        conv_gaF_ga16
 
 static INLINE long
 conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
@@ -435,9 +447,9 @@ conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA8_rgbAF conv_rgba8_rgbaF
-#define conv_gA8_gAF     conv_ga8_gaF
-#define conv_g8_gF       conv_8_F
+#define conv_rgbA8_rgbAF    conv_rgba8_rgbaF
+#define conv_gA8_gAF        conv_ga8_gaF
+#define conv_g8_gF          conv_8_F
 
 static INLINE long
 conv_rgba16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
@@ -460,9 +472,9 @@ conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA16_rgbAF conv_rgba16_rgbaF
-#define conv_gA16_gAF     conv_ga16_gaF
-#define conv_g16_gF       conv_16_F
+#define conv_rgbA16_rgbAF    conv_rgba16_rgbaF
+#define conv_gA16_gAF        conv_ga16_gaF
+#define conv_g16_gF          conv_16_F
 
 static INLINE long
 conv_rgba16_rgba8 (unsigned char *src, unsigned char *dst, long samples)
@@ -485,9 +497,9 @@ conv_ga16_ga8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA16_rgbA8 conv_rgba16_rgba8
-#define conv_gA16_gA8     conv_ga16_ga8
-#define conv_g16_g8       conv_16_8
+#define conv_rgbA16_rgbA8    conv_rgba16_rgba8
+#define conv_gA16_gA8        conv_ga16_ga8
+#define conv_g16_g8          conv_16_8
 
 static INLINE long
 conv_rgba8_rgba16 (unsigned char *src, unsigned char *dst, long samples)
@@ -510,26 +522,27 @@ conv_ga8_ga16 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA8_rgbA16 conv_rgba8_rgba16
-#define conv_gA8_gA16     conv_ga8_ga16
-#define conv_g8_g16       conv_8_16
+#define conv_rgbA8_rgbA16    conv_rgba8_rgba16
+#define conv_gA8_gA16        conv_ga8_ga16
+#define conv_g8_g16          conv_8_16
 
 /* alpha conversions */
 
 static INLINE long
 conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) (src + 4));
+      float alpha = (*(float *) (src + 4));
 
       *(float *) dst = ((*(float *) src) * alpha);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
       *(float *) dst = alpha;
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -537,17 +550,18 @@ conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) (src + 4));
+      float alpha = (*(float *) (src + 4));
 
       *(float *) dst = ((*(float *) src) / alpha);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
       *(float *) dst = alpha;
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -555,18 +569,19 @@ conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) (src + 4 * 3));
-      int       c;
+      float alpha = (*(float *) (src + 4 * 3));
+      int   c;
       if (alpha >= 1.0)
         {
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = *(float *) src;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else if (alpha <= 0.0)
@@ -574,8 +589,8 @@ conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = 0;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else
@@ -583,13 +598,13 @@ conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = ((*(float *) src) / alpha);
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       *(float *) dst = alpha;
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -597,19 +612,20 @@ conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) (src + 4 * 3));
-      int       c;
+      float alpha = (*(float *) (src + 4 * 3));
+      int   c;
 
       if (alpha >= 1.0)
         {
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = *(float *) src;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else if (alpha <= 0.0)
@@ -617,8 +633,8 @@ conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = 0;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else
@@ -626,13 +642,13 @@ conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = ((*(float *) src) * alpha);
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       *(float *) dst = alpha;
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -642,19 +658,20 @@ conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
+      dst         += 4;
+      src         += 4;
       *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
+      dst         += 4;
+      src         += 4;
       *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
-      src += 4;
+      dst         += 4;
+      src         += 4;
+      src         += 4;
     }
   return samples;
 }
@@ -662,20 +679,21 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
-      *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
-      *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      src           += 4;
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      src           += 4;
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      src           += 4;
       *(float *) dst = 1.0;
-      dst += 4;
+      dst           += 4;
     }
   return samples;
 }
@@ -683,13 +701,14 @@ conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
-      src += 4;
+      dst         += 4;
+      src         += 4;
+      src         += 4;
     }
   return samples;
 }
@@ -697,38 +716,40 @@ conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
+      *(int *) dst   = (*(int *) src);
+      dst           += 4;
+      src           += 4;
       *(float *) dst = 1.0;
-      dst += 4;
+      dst           += 4;
     }
   return samples;
 }
 
-#define conv_gAF_gF conv_gaF_gF
-#define conv_gF_gAF conv_gF_gaF
+#define conv_gAF_gF        conv_gaF_gF
+#define conv_gF_gAF        conv_gF_gaF
 
-#define conv_rgbAF_rgbF conv_rgbaF_rgbF
-#define conv_rgbF_rgbAF conv_rgbF_rgbaF
+#define conv_rgbAF_rgbF    conv_rgbaF_rgbF
+#define conv_rgbF_rgbAF    conv_rgbF_rgbaF
 
 /* colorchannel dropping and adding */
 
 static INLINE long
 conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           (*(int *) dst) = (*(int *) src);
-          dst += 4;
+          dst           += 4;
         }
       src += 4;
     }
@@ -738,20 +759,21 @@ conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbF_gF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
-      float     sum = 0;
+      int   c;
+      float sum = 0;
 
       for (c = 0; c < 3; c++)
         {
           sum += (*(float *) src);
           src += 4;
         }
-      sum /= 3;
+      sum             /= 3;
       (*(float *) dst) = sum;
-      dst += 4;
+      dst             += 4;
     }
   return samples;
 }
@@ -759,20 +781,21 @@ conv_rgbF_gF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           (*(int *) dst) = (*(int *) src);
-          dst += 4;
+          dst           += 4;
         }
-      src += 4;
+      src           += 4;
       (*(int *) dst) = (*(int *) src);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -780,11 +803,12 @@ conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_gaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
-      float     sum = 0;
+      int   c;
+      float sum = 0;
 
       for (c = 0; c < 3; c++)
         {
@@ -792,38 +816,38 @@ conv_rgbaF_gaF (unsigned char *src, unsigned char *dst, long samples)
           src += 4;
         }
       (*(float *) dst) = sum / 3;
-      dst += 4;
-      (*(int *) dst) = (*(int *) src);
-      dst += 4;
-      src += 4;
-
+      dst             += 4;
+      (*(int *) dst)   = (*(int *) src);
+      dst             += 4;
+      src             += 4;
     }
   return samples;
 }
 
-#define conv_gAF_rgbAF conv_gaF_rgbaF
-#define conv_rgbAF_gAF conv_rgbaF_gaF
+#define conv_gAF_rgbAF    conv_gaF_rgbaF
+#define conv_rgbAF_gAF    conv_rgbaF_gaF
 
 /* other conversions coded for some optimisation reason or sumthin */
 
 static INLINE long
 conv_rgbA8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(unsigned char *) src + (3)) / 255.0;
-      int       c;
+      float alpha = (*(unsigned char *) src + (3)) / 255.0;
+      int   c;
 
       for (c = 0; c < 3; c++)
         {
           (*(float *) dst) = (*(unsigned char *) src / 255.0) / alpha;
-          dst += 4;
-          src += 1;
+          dst             += 4;
+          src             += 1;
         }
       *(float *) dst = alpha;
-      dst += 4;
-      src += 1;
+      dst           += 4;
+      src           += 1;
     }
   return samples;
 }
@@ -831,17 +855,18 @@ conv_rgbA8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) (src + (4 * 3)));
-      int       c;
+      float alpha = (*(float *) (src + (4 * 3)));
+      int   c;
 
       for (c = 0; c < 3; c++)
         {
           *(unsigned char *) dst = ((*(float *) src) * alpha) * 255.0;
-          dst += 1;
-          src += 4;
+          dst                   += 1;
+          src                   += 4;
         }
       *(unsigned char *) dst = alpha * 255.0;
       dst++;
@@ -853,21 +878,22 @@ conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgbA16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) src + (4 * 3));
-      int       c;
+      float alpha = (*(float *) src + (4 * 3));
+      int   c;
 
       for (c = 0; c < 3; c++)
         {
           *(unsigned short *) dst = ((*(float *) src) * alpha) * 65535.0;
-          dst += 2;
-          src += 4;
+          dst                    += 2;
+          src                    += 4;
         }
       *(unsigned short *) dst = alpha * 65535.0;
-      dst += 2;
-      src += 4;
+      dst                    += 2;
+      src                    += 4;
     }
   return samples;
 }
@@ -875,16 +901,17 @@ conv_rgbaF_rgbA16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           *(unsigned char *) dst = (*(float *) src) * 255.0;
-          dst += 1;
-          src += 4;
+          dst                   += 1;
+          src                   += 4;
         }
       src += 4;
     }
@@ -894,11 +921,12 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_g8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
-      float     sum = 0;
+      int   c;
+      float sum = 0;
 
       for (c = 0; c < 3; c++)
         {
@@ -915,16 +943,17 @@ conv_rgbaF_g8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           *(unsigned short *) dst = (*(float *) src) * 65535.0;
-          dst += 2;
-          src += 4;
+          dst                    += 2;
+          src                    += 4;
         }
       src += 4;
     }
@@ -934,20 +963,21 @@ conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbP8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           (*(float *) dst) = *(unsigned char *) src / 255.0;
-          dst += 4;
-          src += 1;
+          dst             += 4;
+          src             += 1;
         }
       (*(float *) dst) = 1.0;
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
     }
   return samples;
 }
@@ -955,35 +985,36 @@ conv_rgbP8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(unsigned short *) src + (3)) / 65535.0;
-      int       c;
+      float alpha = (*(unsigned short *) src + (3)) / 65535.0;
+      int   c;
 
       for (c = 0; c < 3; c++)
         {
           (*(float *) dst) = (*(unsigned short *) src / 65535.0) / alpha;
-          dst += 4;
-          src += 2;
+          dst             += 4;
+          src             += 2;
         }
       *(float *) dst = alpha;
-      dst += 4;
-      src += 2;
+      dst           += 4;
+      src           += 2;
     }
   return samples;
 }
 
 /*
-static INLINE long
-conv_rgb8_rgbaF (unsigned char *src,
+   static INLINE long
+   conv_rgb8_rgbaF (unsigned char *src,
                  unsigned char *dst,
                  int samples)
-{
+   {
     long n=samples;
     while (n--) {
         int c;
+
         for (c = 0; c < 3; c++) {
             (*(float *) dst) = *(unsigned char *) src / 255.0;
             dst += 4;
@@ -992,14 +1023,14 @@ conv_rgb8_rgbaF (unsigned char *src,
         (*(float *) dst) = 1.0;
         dst += 4;
     }
-  return samples;
-}
-static INLINE long
-conv_g8_rgbaF (unsigned char *src,
+   return samples;
+   }
+
+   static INLINE long
+   conv_g8_rgbaF (unsigned char *src,
                unsigned char *dst,
                int samples)
-{
+   {
     long n=samples;
     while (n--) {
         int c;
@@ -1012,35 +1043,35 @@ conv_g8_rgbaF (unsigned char *src,
         (*(float *) dst) = 1.0;
         dst += 4;
     }
-  return samples;
-}
+   return samples;
+   }
 
-static INLINE long
-conv_rgb16_rgbaF (unsigned char *src,
+   static INLINE long
+   conv_rgb16_rgbaF (unsigned char *src,
                   unsigned char *dst,
                   int samples)
-{
+   {
     long n=samples;
     while (n--) {
         int c;
 
         for (c = 0; c < 3; c++) {
           *(float *) dst = (*(unsigned short *) src) / 65535.0;
+ *(float *) dst = (*(unsigned short *) src) / 65535.0;
             src += 2;
             dst += 4;
         }
       *(float *) dst = 1.0;
+ *(float *) dst = 1.0;
         src += 2;
         dst += 4;
     }
-  return samples;
-}
+   return samples;
+   }
 
-static INLINE long
-conv_gF_rgbaF (unsigned char *src,
+   static INLINE long
+   conv_gF_rgbaF (unsigned char *src,
                unsigned char *dst,
                int samples)
-{
+   {
     long n=samples;
     while (n--) {
         (*(float *) dst) = (*(float *) src);
@@ -1054,13 +1085,14 @@ conv_gF_rgbaF (unsigned char *src,
         src += 4;
 
     }
-  return samples;
-}
-*/
+   return samples;
+   }
+ */
 static INLINE long
 conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       if (src[3] == 255)
@@ -1087,18 +1119,19 @@ conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       if (src[3] == 255)
         {
           *(unsigned int *) dst = *(unsigned int *) src;
-          dst += 4;
+          dst                  += 4;
         }
       else if (src[3] == 0)
         {
           *(unsigned int *) dst = 0;
-          dst += 4;
+          dst                  += 4;
         }
       else
         {
@@ -1116,15 +1149,16 @@ conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_argb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = src[3];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1132,15 +1166,16 @@ conv_argb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgba8_argb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[3];
       dst[1] = src[0];
       dst[2] = src[1];
       dst[3] = src[2];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1148,15 +1183,16 @@ conv_rgba8_argb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_Argb8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = src[3];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1164,15 +1200,16 @@ conv_Argb8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA8_Argb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = src[3];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1180,15 +1217,16 @@ conv_rgbA8_Argb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_Prgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = 255;
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1196,15 +1234,16 @@ conv_Prgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbP8_Prgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = 255;
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1212,7 +1251,8 @@ conv_rgbP8_Prgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_Prgb8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
@@ -1230,15 +1270,16 @@ conv_Prgb8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_Prgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];          /* blue */
       dst[1] = src[1];          /* green */
       dst[2] = src[0];          /* red */
       dst[3] = 255;
-      src += 3;
-      dst += 4;
+      src   += 3;
+      dst   += 4;
     }
   return samples;
 }
@@ -1246,7 +1287,8 @@ conv_rgb8_Prgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA16_rgba16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       if (src[3])
@@ -1259,8 +1301,8 @@ conv_rgbA16_rgba16 (unsigned char *src, unsigned char *dst, long samples)
             (((unsigned short *) src)[2] * 65535) / src[3];
         }
       ((unsigned short *) dst)[3] = ((unsigned short *) src)[3];
-      dst += 8;
-      src += 8;
+      dst                        += 8;
+      src                        += 8;
     }
   return samples;
 }
@@ -1268,14 +1310,15 @@ conv_rgbA16_rgba16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[0];
       dst[1] = src[1];
       dst[2] = src[2];
-      src += 3;
-      dst += 4;
+      src   += 3;
+      dst   += 4;
     }
   return samples;
 }
@@ -1283,37 +1326,39 @@ conv_rgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples; 
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[0];
       dst[1] = src[1];
       dst[2] = src[2];
       dst[3] = 255;
-      src += 3;
-      dst += 4;
+      src   += 3;
+      dst   += 4;
     }
 
   return samples;
 }
 
-#define conv_rgb8_rgbA8 conv_rgb8_rgba8
+#define conv_rgb8_rgbA8    conv_rgb8_rgba8
 
 static INLINE long
 conv_rgbP8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples; 
+  long n = samples;
+
   while (n--)
     {
       *(unsigned int *) dst = *(unsigned int *) src;
-      dst[3] = 255;
-      src += 4;
-      dst += 4;
+      dst[3]                = 255;
+      src                  += 4;
+      dst                  += 4;
     }
   return samples;
 }
 
-#define conv_rgbP8_rgbA8 conv_rgbP8_rgba8
+#define conv_rgbP8_rgbA8    conv_rgbP8_rgba8
 
 static INLINE long
 conv_rgba8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
@@ -1322,19 +1367,20 @@ conv_rgba8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA8_rgbP8 conv_rgba8_rgbP8
+#define conv_rgbA8_rgbP8    conv_rgba8_rgbP8
 
 static INLINE long
 conv_rgbP8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[0];
       dst[1] = src[1];
       dst[2] = src[2];
-      src += 4;
-      dst += 3;
+      src   += 4;
+      dst   += 3;
     }
   return samples;
 }
@@ -1342,56 +1388,58 @@ conv_rgbP8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[0];
       dst[1] = src[1];
       dst[2] = src[2];
-      src += 4;
-      dst += 3;
+      src   += 4;
+      dst   += 3;
     }
   return samples;
 }
 
-#define conv_rgbA8_rgb8 conv_rgbP8_rgb8
+#define conv_rgbA8_rgb8    conv_rgbP8_rgb8
 
 #ifndef byteclamp
-#define byteclamp(j) do{if(j<0)j=0; else if(j>255)j=255;}while(0)
+#define byteclamp(j)                   do { if (j < 0) j = 0;else if (j > 255) j = 255; } while (0)
 #endif
 
-#define YUV82RGB8(Y,U,V,R,G,B)do{\
-            R= ((Y<<15)                 + 37355*(V-128))>>15;\
-            G= ((Y<<15) -12911* (U-128) - 19038*(V-128))>>15;\
-            B= ((Y<<15) +66454* (U-128)                )>>15;\
-            byteclamp(R);\
-            byteclamp(G);\
-            byteclamp(B);\
-}while(0)
-
-#define RGB82YUV8(R,G,B,Y,U,V)do{\
-            Y= (( 9798*R + 19234*G + 3736*B)>>15)  +000;\
-            U= ((-4817*R - 9470*G + 14320*B)>>15)  +128;\
-            V= (( 20152*R - 16875*G - 3277*B)>>15) +128;\
-            byteclamp(Y);\
-            byteclamp(U);\
-            byteclamp(V);\
-}while(0)
+#define YUV82RGB8(Y, U, V, R, G, B)    do { \
+      R = ((Y << 15) + 37355 * (V - 128)) >> 15; \
+      G = ((Y << 15) - 12911 * (U - 128) - 19038 * (V - 128)) >> 15; \
+      B = ((Y << 15) + 66454 * (U - 128)) >> 15; \
+      byteclamp (R); \
+      byteclamp (G); \
+      byteclamp (B); \
+    } while (0)
+
+#define RGB82YUV8(R, G, B, Y, U, V)    do { \
+      Y = ((9798 * R + 19234 * G + 3736 * B) >> 15) + 000; \
+      U = ((-4817 * R - 9470 * G + 14320 * B) >> 15) + 128; \
+      V = ((20152 * R - 16875 * G - 3277 * B) >> 15) + 128; \
+      byteclamp (Y); \
+      byteclamp (U); \
+      byteclamp (V); \
+    } while (0)
 
 static INLINE long
 conv_yuv8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       R, G, B;
+      int R, G, B;
 
       YUV82RGB8 (src[0], src[1], src[2], R, G, B);
       dst[0] = R;
       dst[1] = G;
       dst[2] = B;
-      src += 3;
-      dst += 3;
+      src   += 3;
+      dst   += 3;
     }
   return samples;
 }
@@ -1399,17 +1447,18 @@ conv_yuv8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_yuv8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       Y, U, V;
+      int Y, U, V;
 
       YUV82RGB8 (src[0], src[1], src[2], Y, U, V);
       dst[0] = Y;
       dst[1] = U;
       dst[2] = V;
-      src += 3;
-      dst += 3;
+      src   += 3;
+      dst   += 3;
     }
   return samples;
 }
@@ -1417,21 +1466,22 @@ conv_rgb8_yuv8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_yuvaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     R, G, B;
-      float     Y, U, V;
+      float R, G, B;
+      float Y, U, V;
 
       R = src_f[0];
       G = src_f[1];
       B = src_f[2];
 
       Y = 0.299 * R + 0.587 * B + 0.114 * B;
-      U = (-0.1687) * R - 0.3313 * G + 0.5 * B /* +0.5 */ ;
-      V = 0.5 * R - 0.4187 * G - 0.0813 * B /* +0.5 */ ;
+      U = (-0.1687) * R - 0.3313 * G + 0.5 * B /* +0.5 */;
+      V = 0.5 * R - 0.4187 * G - 0.0813 * B /* +0.5 */;
 
       dst_f[0] = Y;
       dst_f[1] = U;
@@ -1447,21 +1497,22 @@ conv_rgbaF_yuvaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_yuvaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     Y, U, V;
-      float     R, G, B;
+      float Y, U, V;
+      float R, G, B;
 
       Y = src_f[0];
       U = src_f[1];
       V = src_f[2];
 
-      R = Y + 1.40200 * (V /*-0.5*/ );
-      G = Y - 0.34414 * (U /*-0.5*/ ) - 0.71414 * (V /*-0.5*/ );
-      B = Y + 1.77200 * (U /*-0.5*/ );
+      R = Y + 1.40200 * (V /*-0.5*/);
+      G = Y - 0.34414 * (U /*-0.5*/) -0.71414 * (V /*-0.5*/);
+      B = Y + 1.77200 * (U /*-0.5*/);
 
       dst_f[0] = R;
       dst_f[1] = G;
@@ -1479,21 +1530,22 @@ conv_yuvaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbF_yuvF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     R, G, B;
-      float     Y, U, V;
+      float R, G, B;
+      float Y, U, V;
 
       R = src_f[0];
       G = src_f[1];
       B = src_f[2];
 
       Y = 0.299 * R + 0.587 * B + 0.114 * B;
-      U = (-0.1687) * R - 0.3313 * G + 0.5 * B /* +0.5 */ ;
-      V = 0.5 * R - 0.4187 * G - 0.0813 * B /* +0.5 */ ;
+      U = (-0.1687) * R - 0.3313 * G + 0.5 * B /* +0.5 */;
+      V = 0.5 * R - 0.4187 * G - 0.0813 * B /* +0.5 */;
 
       dst_f[0] = Y;
       dst_f[1] = U;
@@ -1508,21 +1560,22 @@ conv_rgbF_yuvF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_yuvF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     Y, U, V;
-      float     R, G, B;
+      float Y, U, V;
+      float R, G, B;
 
       Y = src_f[0];
       U = src_f[1];
       V = src_f[2];
 
-      R = Y + 1.40200 * (V /*-0.5*/ );
-      G = Y - 0.34414 * (U /*-0.5*/ ) - 0.71414 * (V /*-0.5*/ );
-      B = Y + 1.77200 * (U /*-0.5*/ );
+      R = Y + 1.40200 * (V /*-0.5*/);
+      G = Y - 0.34414 * (U /*-0.5*/) -0.71414 * (V /*-0.5*/);
+      B = Y + 1.77200 * (U /*-0.5*/);
 
       dst_f[0] = R;
       dst_f[1] = G;
@@ -1540,18 +1593,18 @@ conv_yuvF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 #include <math.h>
 
 /*
-static const double Xn = 0.951;
-static const double Yn = 1.0;
-static const double Zn = 1.089;
-*/
+   static const double Xn = 0.951;
+   static const double Yn = 1.0;
+   static const double Zn = 1.089;
+ */
 
-#define LXN 0.312713F
-#define LYN 0.329016F
+#define LXN    0.312713F
+#define LYN    0.329016F
 
 static const double lxn = LXN;
 static const double lyn = LYN;
-static double xnn = LXN / LYN;
-static double znn = (1.0F - (LXN + LYN)) / LYN;
+static double       xnn = LXN / LYN;
+static double       znn = (1.0F - (LXN + LYN)) / LYN;
 
 
 static const double LRAMP = 7.99959199F;
@@ -1559,17 +1612,18 @@ static const double LRAMP = 7.99959199F;
 static INLINE long
 conv_rgbF_xyzF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     x, y, z;
-      float     red, green, blue;
+      float x, y, z;
+      float red, green, blue;
 
-      red = src_f[0];
+      red   = src_f[0];
       green = src_f[1];
-      blue = src_f[2];
+      blue  = src_f[2];
 
       x = 0.431 * red + 0.342 * green + 0.179 * blue;
       y = 0.222 * red + 0.707 * green + 0.071 * blue;
@@ -1578,8 +1632,8 @@ conv_rgbF_xyzF (unsigned char *src, unsigned char *dst, long samples)
       dst_f[0] = x;
       dst_f[1] = y;
       dst_f[2] = z;
-      dst_f += 3;
-      src_f += 3;
+      dst_f   += 3;
+      src_f   += 3;
     }
   return samples;
 }
@@ -1587,16 +1641,17 @@ conv_rgbF_xyzF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_xyzF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
       dst_f[0] = src_f[0];
       dst_f[1] = src_f[1];
       dst_f[2] = src_f[2];
-      dst_f += 3;
-      src_f += 3;
+      dst_f   += 3;
+      src_f   += 3;
     }
   return samples;
 }
@@ -1631,14 +1686,15 @@ ffunc_inv (const double t)
 static INLINE long
 conv_labF_xyzF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     P;
-      float     X, Y, Z;
-      float     L, a, b;
+      float P;
+      float X, Y, Z;
+      float L, a, b;
 
       L = src_f[0];
       a = src_f[1];
@@ -1656,16 +1712,16 @@ conv_labF_xyzF (unsigned char *src, unsigned char *dst, long samples)
         }
 
       X = (P + a / 500.0F);
-      X = xnn * ffunc_inv (X);
+      X = xnn *ffunc_inv (X);
       Z = (P - b / 200.0F);
-      Z = znn * ffunc_inv (Z);
+      Z = znn *ffunc_inv (Z);
 
 
       dst_f[0] = X;
       dst_f[1] = Y;
       dst_f[2] = Z;
-      dst_f += 3;
-      src_f += 3;
+      dst_f   += 3;
+      src_f   += 3;
     }
   return samples;
 }
@@ -1673,14 +1729,15 @@ conv_labF_xyzF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_xyzF_labF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      double    ffuncY;
-      float     X, Y, Z;
-      float     L, a, b;
+      double ffuncY;
+      float  X, Y, Z;
+      float  L, a, b;
       X = src_f[0];
       Y = src_f[1];
       Z = src_f[2];
@@ -1702,14 +1759,14 @@ conv_xyzF_labF (unsigned char *src, unsigned char *dst, long samples)
         }
 
       ffuncY = ffunc (Y);
-      a = 500.0F * (ffunc (X / xnn) - ffuncY);
-      b = 200.0F * (ffuncY - ffunc (Z / znn));
+      a      = 500.0F * (ffunc (X / xnn) - ffuncY);
+      b      = 200.0F * (ffuncY - ffunc (Z / znn));
 
       dst_f[0] = L;
       dst_f[1] = a;
       dst_f[2] = b;
-      dst_f += 3;
-      src_f += 3;
+      dst_f   += 3;
+      src_f   += 3;
     }
   return samples;
 }
@@ -1717,16 +1774,16 @@ conv_xyzF_labF (unsigned char *src, unsigned char *dst, long samples)
 /******* end of cpercep lift out **/
 
 
-#define MAX_CONVERSIONS 100
+#define MAX_CONVERSIONS    100
 
 typedef struct Conversion
 {
-  int       from_fmt;
-  int       to_fmt;
-  int       cost;               /* cost of function,. calculated as ms to convert 1024*1024 samples */
-  int       loss;               /* 0 maps ok, 1 precision loss, 2 alpha loss, 4 channel loss
+  int from_fmt;
+  int to_fmt;
+  int cost;               /* cost of function,. calculated as ms to convert 1024*1024 samples */
+  int loss;                     /* 0 maps ok, 1 precision loss, 2 alpha loss, 4 channel loss
                                    (should be dwelled further into) */
-  void      (*function) (unsigned char *src, unsigned char *dst, long samples);
+  void (*function)(unsigned char *src, unsigned char *dst, long samples);
 } Conversion;
 
 
@@ -1736,162 +1793,162 @@ int
 init (void)
 {
   Babl *rgbaF = babl_format_new (
-      babl_model ("RGBA"),
-      babl_type  ("float"),
-      babl_component ("R"),
-      babl_component ("G"),
-      babl_component ("B"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RGBA"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
   Babl *rgba16 = babl_format_new (
-      babl_model ("RGBA"),
-      babl_type  ("u16"),
-      babl_component ("R"),
-      babl_component ("G"),
-      babl_component ("B"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RGBA"),
+    babl_type ("u16"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbaD = babl_format_new (
-      babl_model ("RGBA"),
-      babl_type  ("double"),
-      babl_component ("R"),
-      babl_component ("G"),
-      babl_component ("B"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RGBA"),
+    babl_type ("double"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
   Babl *rgba8 = babl_format_new (
-      babl_model ("RGBA"),
-      babl_type  ("u8"),
-      babl_component ("R"),
-      babl_component ("G"),
-      babl_component ("B"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RGBA"),
+    babl_type ("u8"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbAF = babl_format_new (
-      babl_model ("RaGaBaA"),
-      babl_type  ("float"),
-      babl_component ("Ra"),
-      babl_component ("Ga"),
-      babl_component ("Ba"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RaGaBaA"),
+    babl_type ("float"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbA16 = babl_format_new (
-      babl_model ("RaGaBaA"),
-      babl_type  ("u16"),
-      babl_component ("Ra"),
-      babl_component ("Ga"),
-      babl_component ("Ba"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RaGaBaA"),
+    babl_type ("u16"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbA8 = babl_format_new (
-      babl_model ("RaGaBaA"),
-      babl_type  ("u8"),
-      babl_component ("Ra"),
-      babl_component ("Ga"),
-      babl_component ("Ba"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("RaGaBaA"),
+    babl_type ("u8"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbF = babl_format_new (
-      babl_model ("RGB"),
-      babl_type  ("float"),
-      babl_component ("R"),
-      babl_component ("G"),
-      babl_component ("B"),
-      NULL);
+    babl_model ("RGB"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
   Babl *rgb16 = babl_format_new (
-      babl_model ("RGB"),
-      babl_type  ("u16"),
-      babl_component ("R"),
-      babl_component ("G"),
-      babl_component ("B"),
-      NULL);
+    babl_model ("RGB"),
+    babl_type ("u16"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
   Babl *rgb8 = babl_format_new (
-      babl_model ("RGB"),
-      babl_type  ("u8"),
-      babl_component ("R"),
-      babl_component ("G"),
-      babl_component ("B"),
-      NULL);
+    babl_model ("RGB"),
+    babl_type ("u8"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
   Babl *gaF = babl_format_new (
-      babl_model ("YA"),
-      babl_type  ("float"),
-      babl_component ("Y"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("YA"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
   Babl *gAF = babl_format_new (
-      babl_model ("YaA"),
-      babl_type  ("float"),
-      babl_component ("Ya"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("YaA"),
+    babl_type ("float"),
+    babl_component ("Ya"),
+    babl_component ("A"),
+    NULL);
   Babl *gF = babl_format_new (
-      babl_model ("Y"),
-      babl_type  ("float"),
-      babl_component ("Y"),
-      NULL);
+    babl_model ("Y"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    NULL);
   Babl *ga16 = babl_format_new (
-      babl_model ("YA"),
-      babl_type  ("u16"),
-      babl_component ("Y"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("YA"),
+    babl_type ("u16"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
   Babl *gA16 = babl_format_new (
-      babl_model ("YaA"),
-      babl_type  ("u16"),
-      babl_component ("Ya"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("YaA"),
+    babl_type ("u16"),
+    babl_component ("Ya"),
+    babl_component ("A"),
+    NULL);
   Babl *g16 = babl_format_new (
-      babl_model ("Y"),
-      babl_type  ("u16"),
-      babl_component ("Y"),
-      NULL);
+    babl_model ("Y"),
+    babl_type ("u16"),
+    babl_component ("Y"),
+    NULL);
   Babl *ga8 = babl_format_new (
-      babl_model ("YA"),
-      babl_type  ("u8"),
-      babl_component ("Y"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("YA"),
+    babl_type ("u8"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
   Babl *gA8 = babl_format_new (
-      babl_model ("YaA"),
-      babl_type  ("u8"),
-      babl_component ("Ya"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("YaA"),
+    babl_type ("u8"),
+    babl_component ("Ya"),
+    babl_component ("A"),
+    NULL);
   Babl *g8 = babl_format_new (
-      babl_model ("Y"),
-      babl_type  ("u8"),
-      babl_component ("Y"),
-      NULL);
+    babl_model ("Y"),
+    babl_type ("u8"),
+    babl_component ("Y"),
+    NULL);
   Babl *yuv8 = babl_format_new (
-      "name", "Y'CbCr u8",
-      babl_model ("Y'CbCr"),
-      babl_type  ("u8-luma"),
-      babl_component ("Y'"),
-      babl_type  ("u8-chroma"),
-      babl_component ("Cb"),
-      babl_component ("Cr"),
-      NULL);
+    "name", "Y'CbCr u8",
+    babl_model ("Y'CbCr"),
+    babl_type ("u8-luma"),
+    babl_component ("Y'"),
+    babl_type ("u8-chroma"),
+    babl_component ("Cb"),
+    babl_component ("Cr"),
+    NULL);
   Babl *yuvF = babl_format_new (
-      babl_model ("Y'CbCr"),
-      babl_type  ("float"),
-      babl_component ("Y'"),
-      babl_type  ("float"),
-      babl_component ("Cb"),
-      babl_component ("Cr"),
-      NULL);
+    babl_model ("Y'CbCr"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_type ("float"),
+    babl_component ("Cb"),
+    babl_component ("Cr"),
+    NULL);
   Babl *yuvaF = babl_format_new (
-      babl_model ("Y'CbCrA"),
-      babl_type  ("float"),
-      babl_component ("Y'"),
-      babl_type  ("float"),
-      babl_component ("Cb"),
-      babl_component ("Cr"),
-      babl_component ("A"),
-      NULL);
-
-#define o(src,dst) \
-  babl_conversion_new (src, dst, "linear", conv_##src##_##dst, NULL)
+    babl_model ("Y'CbCrA"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_type ("float"),
+    babl_component ("Cb"),
+    babl_component ("Cr"),
+    babl_component ("A"),
+    NULL);
+
+#define o(src, dst) \
+  babl_conversion_new (src, dst, "linear", conv_ ## src ## _ ## dst, NULL)
 
   o (rgbaF, rgbaD);
   o (rgbaD, rgbaF);
index aba024e0911416f3c00ec3099185b442fdbc1498..263c7d029a77f490ac5aeaa406d2b0937804250b 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "babl.h"
 
-#define INLINE inline
+#define INLINE    inline
 
 #include <math.h>
 #include <stdio.h>
@@ -41,7 +41,7 @@
  *
  * due to ability to be able to relicence gggl under a different
  * licence than GPL, I avoided the temptation to look at the
- * source files in the same location, in case I was going to 
+ * source files in the same location, in case I was going to
  * need this piece of code for projects where GPL compatibility
  * was a must.
  *
@@ -54,9 +54,9 @@
 
 /* lookup tables used in conversion */
 
-static float table_8_F[1 << 8];
-static float table_16_F[1 << 16];
-static unsigned char table_F_8[1 << 16];
+static float          table_8_F[1 << 8];
+static float          table_16_F[1 << 16];
+static unsigned char  table_F_8[1 << 16];
 static unsigned short table_F_16[1 << 16];
 
 
@@ -71,7 +71,7 @@ table_init (void)
 
   /* fill tables for conversion from integer to float */
   {
-    int       i;
+    int i;
     for (i = 0; i < 1 << 8; i++)
       {
         table_8_F[i] = (i * 1.0) / 255.0;
@@ -83,7 +83,7 @@ table_init (void)
   {
     union
     {
-      float     f;
+      float          f;
       unsigned short s[2];
     } u;
     u.f = 0.0;
@@ -92,7 +92,7 @@ table_init (void)
 
     for (u.s[1] = 0; u.s[1] < 65535; u.s[1] += 1)
       {
-        unsigned char c;
+        unsigned char  c;
         unsigned short s;
 
         if (u.f <= 0.0)
@@ -115,20 +115,20 @@ table_init (void)
            / if (! ((*hi)%9))
            /         fprintf (stderr, "\n"); */
 
-        table_F_8[u.s[1]] = c;
+        table_F_8[u.s[1]]  = c;
         table_F_16[u.s[1]] = s;
       }
   }
   /* fix tables to ensure 1:1 conversions back and forth */
   if (0)
     {                           /*FIXME: probably not the right way to do it,.. must sit down and scribble on paper */
-      int       i;
+      int i;
       for (i = 0; i < 256; i++)
         {
-          float     f = table_8_F[i];
-          unsigned short *hi = ((unsigned short *)(void*) &f);
-          unsigned short *lo = ((unsigned short *)(void*) &f);
-          *lo = 0;
+          float           f  = table_8_F[i];
+          unsigned short *hi = ((unsigned short *) (void *) &f);
+          unsigned short *lo = ((unsigned short *) (void *) &f);
+          *lo              = 0;
           table_F_8[(*hi)] = i;
         }
     }
@@ -140,7 +140,7 @@ gggl_float_to_index16 (float f)
 {
   union
   {
-    float     f;
+    float          f;
     unsigned short s[2];
   } u;
   u.f = f;
@@ -150,15 +150,16 @@ gggl_float_to_index16 (float f)
 static INLINE long
 conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       register float f = (*(float *) src);
       *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      dst += 1;
-      src += 4;
+      dst                   += 1;
+      src                   += 4;
     }
   return samples;
 }
@@ -166,15 +167,16 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       register float f = (*(float *) src);
       *(unsigned short *) dst = table_F_16[gggl_float_to_index16 (f)];
-      dst += 2;
-      src += 4;
+      dst                    += 2;
+      src                    += 4;
     }
   return samples;
 }
@@ -182,14 +184,15 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       (*(float *) dst) = table_8_F[*(unsigned char *) src];
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
     }
   return samples;
 }
@@ -197,14 +200,15 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_16_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   if (!table_inited)
     table_init ();
   while (n--)
     {
       (*(float *) dst) = table_16_F[*(unsigned short *) src];
-      dst += 4;
-      src += 2;
+      dst             += 4;
+      src             += 2;
     }
   return samples;
 }
@@ -214,10 +218,11 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float f  = ((*(float *) src));
+      float f    = ((*(float *) src));
       int   uval = rint (f * 255.0);
 
       if (uval < 0) uval = 0;
@@ -233,10 +238,11 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     f = ((*(float *) src));
+      float f = ((*(float *) src));
       if (f < 0.0)
         {
           *(unsigned short *) dst = 0;
@@ -258,12 +264,13 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(float *) dst) = ((*(unsigned char *) src) / 255.0);
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
     }
   return samples;
 }
@@ -271,12 +278,13 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_16_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(float *) dst) = *(unsigned short *) src / 65535.0;
-      dst += 4;
-      src += 2;
+      dst             += 4;
+      src             += 2;
     }
   return samples;
 }
@@ -288,12 +296,13 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_F_D (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(double *) dst = ((*(float *) src));
-      dst += 8;
-      src += 4;
+      dst            += 8;
+      src            += 4;
     }
   return samples;
 }
@@ -301,12 +310,13 @@ conv_F_D (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_D_F (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(float *) dst = ((*(double *) src));
-      dst += 4;
-      src += 8;
+      dst           += 4;
+      src           += 8;
     }
   return samples;
 }
@@ -314,12 +324,13 @@ conv_D_F (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_16_8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(unsigned char *) dst) = (*(unsigned short *) src) >> 8;
-      dst += 1;
-      src += 2;
+      dst                     += 1;
+      src                     += 2;
     }
   return samples;
 }
@@ -327,12 +338,13 @@ conv_16_8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_8_16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       (*(unsigned short *) dst) = (*(unsigned char *) src) << 8;
-      dst += 2;
-      src += 1;
+      dst                      += 2;
+      src                      += 1;
     }
   return samples;
 }
@@ -340,27 +352,27 @@ conv_8_16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
-  {
+    {
       register float f = (*(float *) src);
       *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
-      f = (*(float *) src);
+      f                      = (*(float *) src);
       *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
-      f = (*(float *) src);
+      f                      = (*(float *) src);
       *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      src += 4;
-      dst += 1;
+      src                   += 4;
+      dst                   += 1;
 
       src += 4;
-
-  }
+    }
   return samples;
 }
 
@@ -373,7 +385,7 @@ conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbaF_rgbP8 conv_rgbaF_rgba8
+#define conv_rgbaF_rgbP8    conv_rgbaF_rgba8
 
 static INLINE long
 conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
@@ -389,9 +401,9 @@ conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbAF_rgbA8 conv_rgbaF_rgba8
-#define conv_gF_g8       conv_F_8
-#define conv_gAF_gA8     conv_gaF_ga8
+#define conv_rgbAF_rgbA8    conv_rgbaF_rgba8
+#define conv_gF_g8          conv_F_8
+#define conv_gAF_gA8        conv_gaF_ga8
 
 static INLINE long
 conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples)
@@ -414,9 +426,9 @@ conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbAF_rgbA16 conv_rgbaF_rgba16
-#define conv_gF_g16       conv_F_16
-#define conv_gAF_gA16     conv_gaF_ga16
+#define conv_rgbAF_rgbA16    conv_rgbaF_rgba16
+#define conv_gF_g16          conv_F_16
+#define conv_gAF_gA16        conv_gaF_ga16
 
 static INLINE long
 conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
@@ -436,9 +448,9 @@ conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples)
   return conv_8_F (src, dst, samples * 2) / 2;
 }
 
-#define conv_rgbA8_rgbAF conv_rgba8_rgbaF
-#define conv_gA8_gAF     conv_ga8_gaF
-#define conv_g8_gF       conv_8_F
+#define conv_rgbA8_rgbAF    conv_rgba8_rgbaF
+#define conv_gA8_gAF        conv_ga8_gaF
+#define conv_g8_gF          conv_8_F
 
 static INLINE long
 conv_rgbaF_rgbaD (unsigned char *src, unsigned char *dst, long samples)
@@ -475,9 +487,9 @@ conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA16_rgbAF conv_rgba16_rgbaF
-#define conv_gA16_gAF     conv_ga16_gaF
-#define conv_g16_gF       conv_16_F
+#define conv_rgbA16_rgbAF    conv_rgba16_rgbaF
+#define conv_gA16_gAF        conv_ga16_gaF
+#define conv_g16_gF          conv_16_F
 
 static INLINE long
 conv_rgba16_rgba8 (unsigned char *src, unsigned char *dst, long samples)
@@ -500,9 +512,9 @@ conv_ga16_ga8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA16_rgbA8 conv_rgba16_rgba8
-#define conv_gA16_gA8     conv_ga16_ga8
-#define conv_g16_g8       conv_16_8
+#define conv_rgbA16_rgbA8    conv_rgba16_rgba8
+#define conv_gA16_gA8        conv_ga16_ga8
+#define conv_g16_g8          conv_16_8
 
 static INLINE long
 conv_rgba8_rgba16 (unsigned char *src, unsigned char *dst, long samples)
@@ -525,26 +537,27 @@ conv_ga8_ga16 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA8_rgbA16 conv_rgba8_rgba16
-#define conv_gA8_gA16     conv_ga8_ga16
-#define conv_g8_g16       conv_8_16
+#define conv_rgbA8_rgbA16    conv_rgba8_rgba16
+#define conv_gA8_gA16        conv_ga8_ga16
+#define conv_g8_g16          conv_8_16
 
 /* alpha conversions */
 
 static INLINE long
 conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) (src + 4));
+      float alpha = (*(float *) (src + 4));
 
       *(float *) dst = ((*(float *) src) * alpha);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
       *(float *) dst = alpha;
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -552,17 +565,18 @@ conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) (src + 4));
+      float alpha = (*(float *) (src + 4));
 
       *(float *) dst = ((*(float *) src) / alpha);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
       *(float *) dst = alpha;
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -570,18 +584,19 @@ conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (((float *) src)[3]);
-      int       c;
+      float alpha = (((float *) src)[3]);
+      int   c;
       if (alpha >= 1.0)
         {
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = *(float *) src;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else if (alpha <= 0.0)
@@ -589,8 +604,8 @@ conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = 0;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else
@@ -598,13 +613,13 @@ conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = ((*(float *) src) / alpha);
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       *(float *) dst = alpha;
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -613,38 +628,39 @@ conv_rgbAF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbAF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (((float *) src)[3]);
+      float alpha = (((float *) src)[3]);
       if (alpha >= 1.0)
         {
-          register int       c;
+          register int c;
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = *(float *) src;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else if (alpha <= 0.0)
         {
-          register int       c;
+          register int c;
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = 0;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else
         {
-          register int       c;
+          register int c;
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = ((*(float *) src) / alpha);
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       src += 4;
@@ -655,19 +671,20 @@ conv_rgbAF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (((float *) src)[3]);
-      int       c;
+      float alpha = (((float *) src)[3]);
+      int   c;
 
       if (alpha >= 1.0)
         {
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = *(float *) src;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else if (alpha <= 0.0)
@@ -675,8 +692,8 @@ conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = 0;
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       else
@@ -684,13 +701,13 @@ conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
           for (c = 0; c < 3; c++)
             {
               *(float *) dst = ((*(float *) src) * alpha);
-              dst += 4;
-              src += 4;
+              dst           += 4;
+              src           += 4;
             }
         }
       *(float *) dst = alpha;
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -700,19 +717,20 @@ conv_rgbaF_rgbAF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(float *) dst = (*(float *) src);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
       *(float *) dst = (*(float *) src);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
       *(float *) dst = (*(float *) src);
-      dst += 4;
-      src += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -720,20 +738,21 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(float *) dst = (*(float *) src);
-      src += 4;
-      dst += 4;
+      src           += 4;
+      dst           += 4;
       *(float *) dst = (*(float *) src);
-      src += 4;
-      dst += 4;
+      src           += 4;
+      dst           += 4;
       *(float *) dst = (*(float *) src);
-      src += 4;
-      dst += 4;
+      src           += 4;
+      dst           += 4;
       *(float *) dst = 1.0;
-      dst += 4;
+      dst           += 4;
     }
   return samples;
 }
@@ -741,13 +760,14 @@ conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(int *) dst = (*(int *) src);
-      dst += 4;
-      src += 4;
-      src += 4;
+      dst         += 4;
+      src         += 4;
+      src         += 4;
     }
   return samples;
 }
@@ -755,38 +775,40 @@ conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       *(float *) dst = (*(float *) src);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
       *(float *) dst = 1.0;
-      dst += 4;
+      dst           += 4;
     }
   return samples;
 }
 
-#define conv_gAF_gF conv_gaF_gF
-#define conv_gF_gAF conv_gF_gaF
+#define conv_gAF_gF        conv_gaF_gF
+#define conv_gF_gAF        conv_gF_gaF
 
-#define conv_rgbAF_rgbF conv_rgbaF_rgbF
-#define conv_rgbF_rgbAF conv_rgbF_rgbaF
+#define conv_rgbAF_rgbF    conv_rgbaF_rgbF
+#define conv_rgbF_rgbAF    conv_rgbF_rgbaF
 
 /* colorchannel dropping and adding */
 
 static INLINE long
 conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           (*(float *) dst) = (*(float *) src);
-          dst += 4;
+          dst             += 4;
         }
       src += 4;
     }
@@ -796,20 +818,21 @@ conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbF_gF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
-      float     sum = 0;
+      int   c;
+      float sum = 0;
 
       for (c = 0; c < 3; c++)
         {
           sum += (*(float *) src);
           src += 4;
         }
-      sum /= 3.0;
+      sum             /= 3.0;
       (*(float *) dst) = sum;
-      dst += 4;
+      dst             += 4;
     }
   return samples;
 }
@@ -817,20 +840,21 @@ conv_rgbF_gF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           (*(int *) dst) = (*(int *) src);
-          dst += 4;
+          dst           += 4;
         }
-      src += 4;
+      src           += 4;
       (*(int *) dst) = (*(int *) src);
-      dst += 4;
-      src += 4;
+      dst           += 4;
+      src           += 4;
     }
   return samples;
 }
@@ -838,50 +862,51 @@ conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_gaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     gray = 0;
+      float gray = 0;
 
-      gray += (*(float *) src) * 0.212671;
-      src += 4;
-      gray += (*(float *) src) * 0.715160;
-      src += 4;
-      gray += (*(float *) src) * 0.072169;
-      src += 4;
+      gray            += (*(float *) src) * 0.212671;
+      src             += 4;
+      gray            += (*(float *) src) * 0.715160;
+      src             += 4;
+      gray            += (*(float *) src) * 0.072169;
+      src             += 4;
       (*(float *) dst) = gray;
-      dst += 4;
-      (*(int *) dst) = (*(int *) src);
-      dst += 4;
-      src += 4;
-
+      dst             += 4;
+      (*(int *) dst)   = (*(int *) src);
+      dst             += 4;
+      src             += 4;
     }
   return samples;
 }
 
-#define conv_gAF_rgbAF conv_gaF_rgbaF
-#define conv_rgbAF_gAF conv_rgbaF_gaF
+#define conv_gAF_rgbAF    conv_gaF_rgbaF
+#define conv_rgbAF_gAF    conv_rgbaF_gaF
 
 /* other conversions coded for some optimisation reason or sumthin */
 
 static INLINE long
 conv_rgbA8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(unsigned char *) src + (3)) / 255.0;
-      int       c;
+      float alpha = (*(unsigned char *) src + (3)) / 255.0;
+      int   c;
 
       for (c = 0; c < 3; c++)
         {
           (*(float *) dst) = (*(unsigned char *) src / 255.0) / alpha;
-          dst += 4;
-          src += 1;
+          dst             += 4;
+          src             += 1;
         }
       *(float *) dst = alpha;
-      dst += 4;
-      src += 1;
+      dst           += 4;
+      src           += 1;
     }
   return samples;
 }
@@ -889,17 +914,18 @@ conv_rgbA8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) (src + (4 * 3)));
-      int       c;
+      float alpha = (*(float *) (src + (4 * 3)));
+      int   c;
 
       for (c = 0; c < 3; c++)
         {
           *(unsigned char *) dst = ((*(float *) src) * alpha) * 255.0;
-          dst += 1;
-          src += 4;
+          dst                   += 1;
+          src                   += 4;
         }
       *(unsigned char *) dst = alpha * 255.0;
       dst++;
@@ -911,21 +937,22 @@ conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgbA16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (*(float *) src + (4 * 3));
-      int       c;
+      float alpha = (*(float *) src + (4 * 3));
+      int   c;
 
       for (c = 0; c < 3; c++)
         {
           *(unsigned short *) dst = ((*(float *) src) * alpha) * 65535.0;
-          dst += 2;
-          src += 4;
+          dst                    += 2;
+          src                    += 4;
         }
       *(unsigned short *) dst = alpha * 65535.0;
-      dst += 2;
-      src += 4;
+      dst                    += 2;
+      src                    += 4;
     }
   return samples;
 }
@@ -933,17 +960,18 @@ conv_rgbaF_rgbA16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
-          int val=rint ((*(float *) src) * 255.0);
-          if (val<0)
+          int val = rint ((*(float *) src) * 255.0);
+          if (val < 0)
             *(unsigned char *) dst = 0;
-          else if (val>255)
+          else if (val > 255)
             *(unsigned char *) dst = 255;
           else
             *(unsigned char *) dst = val;
@@ -959,11 +987,12 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_g8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
-      float     sum = 0;
+      int   c;
+      float sum = 0;
 
       for (c = 0; c < 3; c++)
         {
@@ -980,16 +1009,17 @@ conv_rgbaF_g8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           *(unsigned short *) dst = (*(float *) src) * 65535.0;
-          dst += 2;
-          src += 4;
+          dst                    += 2;
+          src                    += 4;
         }
       src += 4;
     }
@@ -999,20 +1029,21 @@ conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbP8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       c;
+      int c;
 
       for (c = 0; c < 3; c++)
         {
           (*(float *) dst) = *(unsigned char *) src / 255.0;
-          dst += 4;
-          src += 1;
+          dst             += 4;
+          src             += 1;
         }
       (*(float *) dst) = 1.0;
-      dst += 4;
-      src += 1;
+      dst             += 4;
+      src             += 1;
     }
   return samples;
 }
@@ -1020,35 +1051,36 @@ conv_rgbP8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      float     alpha = (((unsigned short *) src)[3]) / 65535.0;
-      int       c;
+      float alpha = (((unsigned short *) src)[3]) / 65535.0;
+      int   c;
 
       for (c = 0; c < 3; c++)
         {
           (*(float *) dst) = (*(unsigned short *) src / 65535.0) / alpha;
-          dst += 4;
-          src += 2;
+          dst             += 4;
+          src             += 2;
         }
       *(float *) dst = alpha;
-      dst += 4;
-      src += 2;
+      dst           += 4;
+      src           += 2;
     }
   return samples;
 }
 
 /*
-static INLINE long
-conv_rgb8_rgbaF (unsigned char *src,
+   static INLINE long
+   conv_rgb8_rgbaF (unsigned char *src,
                  unsigned char *dst,
                  int samples)
-{
+   {
     long n=samples;
     while (n--) {
         int c;
+
         for (c = 0; c < 3; c++) {
             (*(float *) dst) = *(unsigned char *) src / 255.0;
             dst += 4;
@@ -1057,14 +1089,14 @@ conv_rgb8_rgbaF (unsigned char *src,
         (*(float *) dst) = 1.0;
         dst += 4;
     }
-  return samples;
-}
-static INLINE long
-conv_g8_rgbaF (unsigned char *src,
+   return samples;
+   }
+
+   static INLINE long
+   conv_g8_rgbaF (unsigned char *src,
                unsigned char *dst,
                int samples)
-{
+   {
     long n=samples;
     while (n--) {
         int c;
@@ -1077,35 +1109,35 @@ conv_g8_rgbaF (unsigned char *src,
         (*(float *) dst) = 1.0;
         dst += 4;
     }
-  return samples;
-}
+   return samples;
+   }
 
-static INLINE long
-conv_rgb16_rgbaF (unsigned char *src,
+   static INLINE long
+   conv_rgb16_rgbaF (unsigned char *src,
                   unsigned char *dst,
                   int samples)
-{
+   {
     long n=samples;
     while (n--) {
         int c;
 
         for (c = 0; c < 3; c++) {
           *(float *) dst = (*(unsigned short *) src) / 65535.0;
+ *(float *) dst = (*(unsigned short *) src) / 65535.0;
             src += 2;
             dst += 4;
         }
       *(float *) dst = 1.0;
+ *(float *) dst = 1.0;
         src += 2;
         dst += 4;
     }
-  return samples;
-}
+   return samples;
+   }
 
-static INLINE long
-conv_gF_rgbaF (unsigned char *src,
+   static INLINE long
+   conv_gF_rgbaF (unsigned char *src,
                unsigned char *dst,
                int samples)
-{
+   {
     long n=samples;
     while (n--) {
         (*(float *) dst) = (*(float *) src);
@@ -1119,13 +1151,14 @@ conv_gF_rgbaF (unsigned char *src,
         src += 4;
 
     }
-  return samples;
-}
-*/
+   return samples;
+   }
+ */
 static INLINE long
 conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       if (src[3] == 255)
@@ -1152,18 +1185,19 @@ conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       if (src[3] == 255)
         {
           *(unsigned int *) dst = *(unsigned int *) src;
-          dst += 4;
+          dst                  += 4;
         }
       else if (src[3] == 0)
         {
           *(unsigned int *) dst = 0;
-          dst += 4;
+          dst                  += 4;
         }
       else
         {
@@ -1181,15 +1215,16 @@ conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_argb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = src[3];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1197,15 +1232,16 @@ conv_argb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgba8_argb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[3];
       dst[1] = src[0];
       dst[2] = src[1];
       dst[3] = src[2];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1213,15 +1249,16 @@ conv_rgba8_argb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_Argb8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = src[3];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1229,15 +1266,16 @@ conv_Argb8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA8_Argb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = src[3];
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1245,15 +1283,16 @@ conv_rgbA8_Argb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_Prgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = 255;
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1261,15 +1300,16 @@ conv_Prgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbP8_Prgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
       dst[1] = src[1];
       dst[2] = src[0];
       dst[3] = 255;
-      src += 4;
-      dst += 4;
+      src   += 4;
+      dst   += 4;
     }
   return samples;
 }
@@ -1277,7 +1317,8 @@ conv_rgbP8_Prgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_Prgb8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];
@@ -1295,15 +1336,16 @@ conv_Prgb8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_Prgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[2];          /* blue */
       dst[1] = src[1];          /* green */
       dst[2] = src[0];          /* red */
       dst[3] = 255;
-      src += 3;
-      dst += 4;
+      src   += 3;
+      dst   += 4;
     }
   return samples;
 }
@@ -1311,7 +1353,8 @@ conv_rgb8_Prgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA16_rgba16 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       if (src[3])
@@ -1324,8 +1367,8 @@ conv_rgbA16_rgba16 (unsigned char *src, unsigned char *dst, long samples)
             (((unsigned short *) src)[2] * 65535) / src[3];
         }
       ((unsigned short *) dst)[3] = ((unsigned short *) src)[3];
-      dst += 8;
-      src += 8;
+      dst                        += 8;
+      src                        += 8;
     }
   return samples;
 }
@@ -1333,14 +1376,15 @@ conv_rgbA16_rgba16 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[0];
       dst[1] = src[1];
       dst[2] = src[2];
-      src += 3;
-      dst += 4;
+      src   += 3;
+      dst   += 4;
     }
   return samples;
 }
@@ -1348,39 +1392,41 @@ conv_rgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples; 
+  long n = samples;
+
   while (n--)
     {
       /**(unsigned int *) dst = *(unsigned int *) src;
-      dst[3] = 255;*/
+         dst[3] = 255;*/
 
       dst[0] = src[0];
       dst[1] = src[1];
       dst[2] = src[2];
       dst[3] = 255;
-      src += 3;
-      dst += 4;
+      src   += 3;
+      dst   += 4;
     }
   return samples;
 }
 
-#define conv_rgb8_rgbA8 conv_rgb8_rgba8
+#define conv_rgb8_rgbA8    conv_rgb8_rgba8
 
 static INLINE long
 conv_rgbP8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples; 
+  long n = samples;
+
   while (n--)
     {
       *(unsigned int *) dst = *(unsigned int *) src;
-      dst[3] = 255;
-      src += 4;
-      dst += 4;
+      dst[3]                = 255;
+      src                  += 4;
+      dst                  += 4;
     }
   return samples;
 }
 
-#define conv_rgbP8_rgbA8 conv_rgbP8_rgba8
+#define conv_rgbP8_rgbA8    conv_rgbP8_rgba8
 
 static INLINE long
 conv_rgba8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
@@ -1389,19 +1435,20 @@ conv_rgba8_rgbP8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#define conv_rgbA8_rgbP8 conv_rgba8_rgbP8
+#define conv_rgbA8_rgbP8    conv_rgba8_rgbP8
 
 static INLINE long
 conv_rgbP8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[0];
       dst[1] = src[1];
       dst[2] = src[2];
-      src += 4;
-      dst += 3;
+      src   += 4;
+      dst   += 3;
     }
   return samples;
 }
@@ -1409,14 +1456,15 @@ conv_rgbP8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       dst[0] = src[0];
       dst[1] = src[1];
       dst[2] = src[2];
-      src += 4;
-      dst += 3;
+      src   += 4;
+      dst   += 3;
     }
   return samples;
 }
@@ -1424,7 +1472,8 @@ conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbA8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
       int alpha = src[3];
@@ -1453,41 +1502,42 @@ conv_rgbA8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 }
 
 #ifndef byteclamp
-#define byteclamp(j) do{if(j<0)j=0; else if(j>255)j=255;}while(0)
+#define byteclamp(j)                   do { if (j < 0) j = 0;else if (j > 255) j = 255; } while (0)
 #endif
 
-#define YUV82RGB8(Y,U,V,R,G,B)do{\
-            R= ((Y<<15)                 + 37355*(V-128))>>15;\
-            G= ((Y<<15) -12911* (U-128) - 19038*(V-128))>>15;\
-            B= ((Y<<15) +66454* (U-128)                )>>15;\
-            byteclamp(R);\
-            byteclamp(G);\
-            byteclamp(B);\
-}while(0)
-
-#define RGB82YUV8(R,G,B,Y,U,V)do{\
-            Y= (( 9798*R + 19234*G + 3736*B)>>15)  +000;\
-            U= ((-4817*R - 9470*G + 14320*B)>>15)  +128;\
-            V= (( 20152*R - 16875*G - 3277*B)>>15) +128;\
-            byteclamp(Y);\
-            byteclamp(U);\
-            byteclamp(V);\
-}while(0)
+#define YUV82RGB8(Y, U, V, R, G, B)    do { \
+      R = ((Y << 15) + 37355 * (V - 128)) >> 15; \
+      G = ((Y << 15) - 12911 * (U - 128) - 19038 * (V - 128)) >> 15; \
+      B = ((Y << 15) + 66454 * (U - 128)) >> 15; \
+      byteclamp (R); \
+      byteclamp (G); \
+      byteclamp (B); \
+    } while (0)
+
+#define RGB82YUV8(R, G, B, Y, U, V)    do { \
+      Y = ((9798 * R + 19234 * G + 3736 * B) >> 15) + 000; \
+      U = ((-4817 * R - 9470 * G + 14320 * B) >> 15) + 128; \
+      V = ((20152 * R - 16875 * G - 3277 * B) >> 15) + 128; \
+      byteclamp (Y); \
+      byteclamp (U); \
+      byteclamp (V); \
+    } while (0)
 
 static INLINE long
 conv_yuv8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       R, G, B;
+      int R, G, B;
 
       YUV82RGB8 (src[0], src[1], src[2], R, G, B);
       dst[0] = R;
       dst[1] = G;
       dst[2] = B;
-      src += 3;
-      dst += 3;
+      src   += 3;
+      dst   += 3;
     }
   return samples;
 }
@@ -1495,17 +1545,18 @@ conv_yuv8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgb8_yuv8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n=samples;
+  long n = samples;
+
   while (n--)
     {
-      int       Y, U, V;
+      int Y, U, V;
 
       YUV82RGB8 (src[0], src[1], src[2], Y, U, V);
       dst[0] = Y;
       dst[1] = U;
       dst[2] = V;
-      src += 3;
-      dst += 3;
+      src   += 3;
+      dst   += 3;
     }
   return samples;
 }
@@ -1513,21 +1564,22 @@ conv_rgb8_yuv8 (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbaF_yuvaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     R, G, B;
-      float     Y, U, V;
+      float R, G, B;
+      float Y, U, V;
 
       R = src_f[0];
       G = src_f[1];
       B = src_f[2];
 
       Y = 0.299 * R + 0.587 * B + 0.114 * B;
-      U = (-0.1687) * R - 0.3313 * G + 0.5 * B /* +0.5 */ ;
-      V = 0.5 * R - 0.4187 * G - 0.0813 * B /* +0.5 */ ;
+      U = (-0.1687) * R - 0.3313 * G + 0.5 * B /* +0.5 */;
+      V = 0.5 * R - 0.4187 * G - 0.0813 * B /* +0.5 */;
 
       dst_f[0] = Y;
       dst_f[1] = U;
@@ -1543,21 +1595,22 @@ conv_rgbaF_yuvaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_yuvaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     Y, U, V;
-      float     R, G, B;
+      float Y, U, V;
+      float R, G, B;
 
       Y = src_f[0];
       U = src_f[1];
       V = src_f[2];
 
-      R = Y + 1.40200 * (V /*-0.5*/ );
-      G = Y - 0.34414 * (U /*-0.5*/ ) - 0.71414 * (V /*-0.5*/ );
-      B = Y + 1.77200 * (U /*-0.5*/ );
+      R = Y + 1.40200 * (V /*-0.5*/);
+      G = Y - 0.34414 * (U /*-0.5*/) -0.71414 * (V /*-0.5*/);
+      B = Y + 1.77200 * (U /*-0.5*/);
 
       dst_f[0] = R;
       dst_f[1] = G;
@@ -1575,21 +1628,22 @@ conv_yuvaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_rgbF_yuvF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     R, G, B;
-      float     Y, U, V;
+      float R, G, B;
+      float Y, U, V;
 
       R = src_f[0];
       G = src_f[1];
       B = src_f[2];
 
       Y = 0.299 * R + 0.587 * B + 0.114 * B;
-      U = (-0.1687) * R - 0.3313 * G + 0.5 * B /* +0.5 */ ;
-      V = 0.5 * R - 0.4187 * G - 0.0813 * B /* +0.5 */ ;
+      U = (-0.1687) * R - 0.3313 * G + 0.5 * B /* +0.5 */;
+      V = 0.5 * R - 0.4187 * G - 0.0813 * B /* +0.5 */;
 
       dst_f[0] = Y;
       dst_f[1] = U;
@@ -1604,21 +1658,22 @@ conv_rgbF_yuvF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_yuvF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     Y, U, V;
-      float     R, G, B;
+      float Y, U, V;
+      float R, G, B;
 
       Y = src_f[0];
       U = src_f[1];
       V = src_f[2];
 
-      R = Y + 1.40200 * (V /*-0.5*/ );
-      G = Y - 0.34414 * (U /*-0.5*/ ) - 0.71414 * (V /*-0.5*/ );
-      B = Y + 1.77200 * (U /*-0.5*/ );
+      R = Y + 1.40200 * (V /*-0.5*/);
+      G = Y - 0.34414 * (U /*-0.5*/) -0.71414 * (V /*-0.5*/);
+      B = Y + 1.77200 * (U /*-0.5*/);
 
       dst_f[0] = R;
       dst_f[1] = G;
@@ -1636,18 +1691,18 @@ conv_yuvF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 #include <math.h>
 
 /*
-static const double Xn = 0.951;
-static const double Yn = 1.0;
-static const double Zn = 1.089;
-*/
+   static const double Xn = 0.951;
+   static const double Yn = 1.0;
+   static const double Zn = 1.089;
+ */
 
-#define LXN 0.312713F
-#define LYN 0.329016F
+#define LXN    0.312713F
+#define LYN    0.329016F
 
 static const double lxn = LXN;
 static const double lyn = LYN;
-static double xnn = LXN / LYN;
-static double znn = (1.0F - (LXN + LYN)) / LYN;
+static double       xnn = LXN / LYN;
+static double       znn = (1.0F - (LXN + LYN)) / LYN;
 
 
 static const double LRAMP = 7.99959199F;
@@ -1655,17 +1710,18 @@ static const double LRAMP = 7.99959199F;
 static INLINE long
 conv_rgbF_xyzF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     x, y, z;
-      float     red, green, blue;
+      float x, y, z;
+      float red, green, blue;
 
-      red = src_f[0];
+      red   = src_f[0];
       green = src_f[1];
-      blue = src_f[2];
+      blue  = src_f[2];
 
       x = 0.431 * red + 0.342 * green + 0.179 * blue;
       y = 0.222 * red + 0.707 * green + 0.071 * blue;
@@ -1674,8 +1730,8 @@ conv_rgbF_xyzF (unsigned char *src, unsigned char *dst, long samples)
       dst_f[0] = x;
       dst_f[1] = y;
       dst_f[2] = z;
-      dst_f += 3;
-      src_f += 3;
+      dst_f   += 3;
+      src_f   += 3;
     }
   return samples;
 }
@@ -1683,16 +1739,17 @@ conv_rgbF_xyzF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_xyzF_rgbF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
       dst_f[0] = src_f[0];
       dst_f[1] = src_f[1];
       dst_f[2] = src_f[2];
-      dst_f += 3;
-      src_f += 3;
+      dst_f   += 3;
+      src_f   += 3;
     }
   return samples;
 }
@@ -1727,14 +1784,15 @@ ffunc_inv (const double t)
 static INLINE long
 conv_labF_xyzF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      float     P;
-      float     X, Y, Z;
-      float     L, a, b;
+      float P;
+      float X, Y, Z;
+      float L, a, b;
 
       L = src_f[0];
       a = src_f[1];
@@ -1752,16 +1810,16 @@ conv_labF_xyzF (unsigned char *src, unsigned char *dst, long samples)
         }
 
       X = (P + a / 500.0F);
-      X = xnn * ffunc_inv (X);
+      X = xnn *ffunc_inv (X);
       Z = (P - b / 200.0F);
-      Z = znn * ffunc_inv (Z);
+      Z = znn *ffunc_inv (Z);
 
 
       dst_f[0] = X;
       dst_f[1] = Y;
       dst_f[2] = Z;
-      dst_f += 3;
-      src_f += 3;
+      dst_f   += 3;
+      src_f   += 3;
     }
   return samples;
 }
@@ -1769,14 +1827,15 @@ conv_labF_xyzF (unsigned char *src, unsigned char *dst, long samples)
 static INLINE long
 conv_xyzF_labF (unsigned char *src, unsigned char *dst, long samples)
 {
-  float    *src_f = (float *) src;
-  float    *dst_f = (float *) dst;
-  long n=samples;
+  float *src_f = (float *) src;
+  float *dst_f = (float *) dst;
+  long   n     = samples;
+
   while (n--)
     {
-      double    ffuncY;
-      float     X, Y, Z;
-      float     L, a, b;
+      double ffuncY;
+      float  X, Y, Z;
+      float  L, a, b;
       X = src_f[0];
       Y = src_f[1];
       Z = src_f[2];
@@ -1798,14 +1857,14 @@ conv_xyzF_labF (unsigned char *src, unsigned char *dst, long samples)
         }
 
       ffuncY = ffunc (Y);
-      a = 500.0F * (ffunc (X / xnn) - ffuncY);
-      b = 200.0F * (ffuncY - ffunc (Z / znn));
+      a      = 500.0F * (ffunc (X / xnn) - ffuncY);
+      b      = 200.0F * (ffuncY - ffunc (Z / znn));
 
       dst_f[0] = L;
       dst_f[1] = a;
       dst_f[2] = b;
-      dst_f += 3;
-      src_f += 3;
+      dst_f   += 3;
+      src_f   += 3;
     }
   return samples;
 }
@@ -1813,16 +1872,16 @@ conv_xyzF_labF (unsigned char *src, unsigned char *dst, long samples)
 /******* end of cpercep lift out **/
 
 
-#define MAX_CONVERSIONS 100
+#define MAX_CONVERSIONS    100
 
 typedef struct Conversion
 {
-  int       from_fmt;
-  int       to_fmt;
-  int       cost;               /* cost of function,. calculated as ms to convert 1024*1024 samples */
-  int       loss;               /* 0 maps ok, 1 precision loss, 2 alpha loss, 4 channel loss
+  int from_fmt;
+  int to_fmt;
+  int cost;               /* cost of function,. calculated as ms to convert 1024*1024 samples */
+  int loss;                     /* 0 maps ok, 1 precision loss, 2 alpha loss, 4 channel loss
                                    (should be dwelled further into) */
-  void      (*function) (unsigned char *src, unsigned char *dst, long samples);
+  void (*function)(unsigned char *src, unsigned char *dst, long samples);
 } Conversion;
 
 int init (void);
@@ -1831,162 +1890,162 @@ int
 init (void)
 {
   Babl *rgbaD = babl_format_new (
-      babl_model ("R'G'B'A"),
-      babl_type  ("double"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("R'G'B'A"),
+    babl_type ("double"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbaF = babl_format_new (
-      babl_model ("R'G'B'A"),
-      babl_type  ("float"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("R'G'B'A"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
   Babl *rgba16 = babl_format_new (
-      babl_model ("R'G'B'A"),
-      babl_type  ("u16"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("R'G'B'A"),
+    babl_type ("u16"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
   Babl *rgba8 = babl_format_new (
-      babl_model ("R'G'B'A"),
-      babl_type  ("u8"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("R'G'B'A"),
+    babl_type ("u8"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbAF = babl_format_new (
-      babl_model ("R'aG'aB'aA"),
-      babl_type  ("float"),
-      babl_component ("R'a"),
-      babl_component ("G'a"),
-      babl_component ("B'a"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("float"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbA16 = babl_format_new (
-      babl_model ("R'aG'aB'aA"),
-      babl_type  ("u16"),
-      babl_component ("R'a"),
-      babl_component ("G'a"),
-      babl_component ("B'a"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("u16"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbA8 = babl_format_new (
-      babl_model ("R'aG'aB'aA"),
-      babl_type  ("u8"),
-      babl_component ("R'a"),
-      babl_component ("G'a"),
-      babl_component ("B'a"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("u8"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
   Babl *rgbF = babl_format_new (
-      babl_model ("R'G'B'"),
-      babl_type  ("float"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      NULL);
+    babl_model ("R'G'B'"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
   Babl *rgb16 = babl_format_new (
-      babl_model ("R'G'B'"),
-      babl_type  ("u16"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      NULL);
+    babl_model ("R'G'B'"),
+    babl_type ("u16"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
   Babl *rgb8 = babl_format_new (
-      babl_model ("R'G'B'"),
-      babl_type  ("u8"),
-      babl_component ("R'"),
-      babl_component ("G'"),
-      babl_component ("B'"),
-      NULL);
+    babl_model ("R'G'B'"),
+    babl_type ("u8"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
   Babl *gaF = babl_format_new (
-      babl_model ("Y'A"),
-      babl_type  ("float"),
-      babl_component ("Y'"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("Y'A"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
   Babl *gAF = babl_format_new (
-      babl_model ("Y'aA"),
-      babl_type  ("float"),
-      babl_component ("Y'a"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("Y'aA"),
+    babl_type ("float"),
+    babl_component ("Y'a"),
+    babl_component ("A"),
+    NULL);
   Babl *gF = babl_format_new (
-      babl_model ("Y'"),
-      babl_type  ("float"),
-      babl_component ("Y'"),
-      NULL);
+    babl_model ("Y'"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    NULL);
   Babl *ga16 = babl_format_new (
-      babl_model ("Y'A"),
-      babl_type  ("u16"),
-      babl_component ("Y'"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("Y'A"),
+    babl_type ("u16"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
   Babl *gA16 = babl_format_new (
-      babl_model ("Y'aA"),
-      babl_type  ("u16"),
-      babl_component ("Y'a"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("Y'aA"),
+    babl_type ("u16"),
+    babl_component ("Y'a"),
+    babl_component ("A"),
+    NULL);
   Babl *g16 = babl_format_new (
-      babl_model ("Y'"),
-      babl_type  ("u16"),
-      babl_component ("Y'"),
-      NULL);
+    babl_model ("Y'"),
+    babl_type ("u16"),
+    babl_component ("Y'"),
+    NULL);
   Babl *ga8 = babl_format_new (
-      babl_model ("Y'A"),
-      babl_type  ("u8"),
-      babl_component ("Y'"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("Y'A"),
+    babl_type ("u8"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
   Babl *gA8 = babl_format_new (
-      babl_model ("Y'aA"),
-      babl_type  ("u8"),
-      babl_component ("Y'a"),
-      babl_component ("A"),
-      NULL);
+    babl_model ("Y'aA"),
+    babl_type ("u8"),
+    babl_component ("Y'a"),
+    babl_component ("A"),
+    NULL);
   Babl *g8 = babl_format_new (
-      babl_model ("Y'"),
-      babl_type  ("u8"),
-      babl_component ("Y'"),
-      NULL);
+    babl_model ("Y'"),
+    babl_type ("u8"),
+    babl_component ("Y'"),
+    NULL);
   Babl *yuv8 = babl_format_new (
-      "name", "Y'CbCr u8",
-      babl_model ("Y'CbCr"),
-      babl_type  ("u8-luma"),
-      babl_component ("Y'"),
-      babl_type  ("u8-chroma"),
-      babl_component ("Cb"),
-      babl_component ("Cr"),
-      NULL);
+    "name", "Y'CbCr u8",
+    babl_model ("Y'CbCr"),
+    babl_type ("u8-luma"),
+    babl_component ("Y'"),
+    babl_type ("u8-chroma"),
+    babl_component ("Cb"),
+    babl_component ("Cr"),
+    NULL);
   Babl *yuvF = babl_format_new (
-      babl_model ("Y'CbCr"),
-      babl_type  ("float"),
-      babl_component ("Y'"),
-      babl_type  ("float"),
-      babl_component ("Cb"),
-      babl_component ("Cr"),
-      NULL);
+    babl_model ("Y'CbCr"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_type ("float"),
+    babl_component ("Cb"),
+    babl_component ("Cr"),
+    NULL);
   Babl *yuvaF = babl_format_new (
-      babl_model ("Y'CbCrA"),
-      babl_type  ("float"),
-      babl_component ("Y'"),
-      babl_type  ("float"),
-      babl_component ("Cb"),
-      babl_component ("Cr"),
-      babl_component ("A"),
-      NULL);
-
-#define o(src,dst) \
-  babl_conversion_new (src, dst, "linear", conv_##src##_##dst, NULL)
+    babl_model ("Y'CbCrA"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_type ("float"),
+    babl_component ("Cb"),
+    babl_component ("Cr"),
+    babl_component ("A"),
+    NULL);
+
+#define o(src, dst) \
+  babl_conversion_new (src, dst, "linear", conv_ ## src ## _ ## dst, NULL)
 
   o (rgbaF, rgba8);
   o (rgba8, rgbaF);
index ea486d7f0fcbcab7a34730a0db74d7696b8786c6..448fdb79a3dcb38d343f0da246bae602830ce848 100644 (file)
@@ -26,9 +26,9 @@
 static long
 rgba_to_cmyk (char *src,
               char *dst,
-              long   n);
+              long  n);
 
-static long 
+static long
 cmyk_to_rgba (char *src,
               char *dst,
               long  n);
@@ -38,11 +38,10 @@ int init (void);
 int
 init (void)
 {
-
-  babl_component_new ("cyan",    NULL);
-  babl_component_new ("yellow",  NULL);
+  babl_component_new ("cyan", NULL);
+  babl_component_new ("yellow", NULL);
   babl_component_new ("magenta", NULL);
-  babl_component_new ("key",     NULL);
+  babl_component_new ("key", NULL);
 
   babl_model_new (
     "name", "CMYK",
@@ -56,25 +55,25 @@ init (void)
   babl_conversion_new (
     babl_model ("RGBA"),
     babl_model ("CMYK"),
-    "linear",      rgba_to_cmyk,
+    "linear", rgba_to_cmyk,
     NULL
   );
 
   babl_conversion_new (
     babl_model ("CMYK"),
     babl_model ("RGBA"),
-    "linear",      cmyk_to_rgba,
+    "linear", cmyk_to_rgba,
     NULL
   );
   babl_format_new (
-      "name",        "CMYK float",
-      babl_model     ("CMYK"),
-      babl_type      ("float"),
-      babl_component ("cyan"),
-      babl_component ("yellow"),
-      babl_component ("magenta"),
-      babl_component ("key"),
-      NULL
+    "name", "CMYK float",
+    babl_model ("CMYK"),
+    babl_type ("float"),
+    babl_component ("cyan"),
+    babl_component ("yellow"),
+    babl_component ("magenta"),
+    babl_component ("key"),
+    NULL
   );
 
   return 0;
@@ -84,13 +83,13 @@ init (void)
 static long
 rgba_to_cmyk (char *src,
               char *dst,
-              long   n)
+              long  n)
 {
   while (n--)
     {
-      double red   = ((double*)src)[0];
-      double green = ((double*)src)[1];
-      double blue  = ((double*)src)[2];
+      double red   = ((double *) src)[0];
+      double green = ((double *) src)[1];
+      double blue  = ((double *) src)[2];
 
       double cyan, magenta, yellow, key;
 
@@ -101,17 +100,17 @@ rgba_to_cmyk (char *src,
       yellow  = 1.0 - blue;
 
       key = 1.0;
-      if (cyan    < key) key = cyan;
+      if (cyan < key) key = cyan;
       if (magenta < key) key = magenta;
-      if (yellow  < key) key = yellow;
+      if (yellow < key) key = yellow;
 
       key *= pullout;
 
       if (key < 1.0)
         {
-          cyan    = (cyan - key)    / (1.0 -key);
-          magenta = (magenta - key) / (1.0 -key);
-          yellow  = (yellow - key)  / (1.0 -key);
+          cyan    = (cyan - key) / (1.0 - key);
+          magenta = (magenta - key) / (1.0 - key);
+          yellow  = (yellow - key) / (1.0 - key);
         }
       else
         {
@@ -120,36 +119,36 @@ rgba_to_cmyk (char *src,
           yellow  = 0.0;
         }
 
-      ((double*)dst)[0] = cyan;
-      ((double*)dst)[1] = magenta;
-      ((double*)dst)[2] = yellow;
-      ((double*)dst)[3] = key;
+      ((double *) dst)[0] = cyan;
+      ((double *) dst)[1] = magenta;
+      ((double *) dst)[2] = yellow;
+      ((double *) dst)[3] = key;
 
-      src+=4*sizeof(double);
-      dst+=4*sizeof(double);
+      src += 4 * sizeof (double);
+      dst += 4 * sizeof (double);
     }
   return n;
 }
 
-static long 
+static long
 cmyk_to_rgba (char *src,
               char *dst,
               long  n)
 {
   while (n--)
     {
-      double cyan    = ((double*)src)[0];
-      double magenta = ((double*)src)[1];
-      double yellow  = ((double*)src)[2];
-      double key     = ((double*)src)[3];
+      double cyan    = ((double *) src)[0];
+      double magenta = ((double *) src)[1];
+      double yellow  = ((double *) src)[2];
+      double key     = ((double *) src)[3];
 
       double red, green, blue;
 
       if (key < 1.0)
         {
-          cyan    = cyan    * (1.0 - key) + key;
+          cyan    = cyan * (1.0 - key) + key;
           magenta = magenta * (1.0 - key) + key;
-          yellow  = yellow  * (1.0 - key) + key;
+          yellow  = yellow * (1.0 - key) + key;
         }
       else
         {
@@ -160,14 +159,14 @@ cmyk_to_rgba (char *src,
       green = 1.0 - magenta;
       blue  = 1.0 - yellow;
 
-      ((double*)dst)[0] = red;
-      ((double*)dst)[1] = green;
-      ((double*)dst)[2] = blue;
+      ((double *) dst)[0] = red;
+      ((double *) dst)[1] = green;
+      ((double *) dst)[2] = blue;
 
-      ((double*)dst)[3] = 1.0;
+      ((double *) dst)[3] = 1.0;
 
-      src+=4*sizeof(double);
-      dst+=4*sizeof(double);
+      src += 4 * sizeof (double);
+      dst += 4 * sizeof (double);
     }
   return n;
 }
index eda0b2cfd1a6c40a51c3baebb14581056758b0bc..163f0ec6f8caf44989eebe5153fa49345c469696 100644 (file)
 
 #include "babl-internal.h"    /* needed for babl_log */
 
-static void model_html              (Babl *babl);
-static void type_html               (Babl *babl);
-static void format_html             (Babl *babl);
-static void conversion_html         (Babl *babl);
+static void model_html (Babl *babl);
+static void type_html (Babl *babl);
+static void format_html (Babl *babl);
+static void conversion_html (Babl *babl);
 
-static int  each_item               (Babl *babl,
-                                     void *user_data);
-static int  show_item               (Babl *babl,
-                                     void *user_data);
-static int  hide_item               (Babl *babl,
-                                     void *user_data);
+static int  each_item (Babl *babl,
+                       void *user_data);
+static int  show_item (Babl *babl,
+                       void *user_data);
+static int  hide_item (Babl *babl,
+                       void *user_data);
 
 
 int
@@ -73,12 +73,12 @@ main (void)
   printf ("</div>\n");
 
 /*
-  printf ("<div class='expander'>");
-  printf ("<div class='expander_title'><a style='font-size:110%%' name='Conversions' href='javascript:toggle_visible(\"x_conversions\")'>Conversions</a></div><div class='expander_content' id='x_conversions'>\n");
-  babl_conversion_each (each_item, NULL);
-  printf ("</div>\n");
-  printf ("</div>\n");
-*/
+   printf ("<div class='expander'>");
+   printf ("<div class='expander_title'><a style='font-size:110%%' name='Conversions' href='javascript:toggle_visible(\"x_conversions\")'>Conversions</a></div><div class='expander_content' id='x_conversions'>\n");
+   babl_conversion_each (each_item, NULL);
+   printf ("</div>\n");
+   printf ("</div>\n");
+ */
   babl_destroy ();
 
   return 0;
@@ -87,21 +87,22 @@ main (void)
 
 static char normalized_buf[512];
 
-static const char *normalize(const char *str)
+static const char *normalize (const char *str)
 {
   char *s = normalized_buf;
+
   strcpy (normalized_buf, str);
 
   while (*s)
     {
-      if ( (*s >= 'a' && *s <= 'z') ||
-           (*s >= 'A' && *s <= 'Z') ||
-           (*s >= '0' && *s <= '9'))
+      if ((*s >= 'a' && *s <= 'z') ||
+          (*s >= 'A' && *s <= 'Z') ||
+          (*s >= '0' && *s <= '9'))
         {
         }
       else
         {
-          *s='_';
+          *s = '_';
         }
       s++;
     }
@@ -113,7 +114,7 @@ static int
 show_item (Babl *babl,
            void *user_data)
 {
-  printf ("show(\"x_%s\");", normalize(babl->instance.name));
+  printf ("show(\"x_%s\");", normalize (babl->instance.name));
   return 0;
 }
 
@@ -122,7 +123,7 @@ static int
 hide_item (Babl *babl,
            void *user_data)
 {
-  printf ("hide(\"x_%s\");", normalize(babl->instance.name));
+  printf ("hide(\"x_%s\");", normalize (babl->instance.name));
   return 0;
 }
 
@@ -132,9 +133,9 @@ each_item (Babl *babl,
 {
   printf ("<div class='expander'>");
   printf ("<div class='expander_title'><a href='javascript:toggle_visible(\"x_%s\")'>%s</a></div>\n",
-      normalize(babl->instance.name), babl->instance.name);
+          normalize (babl->instance.name), babl->instance.name);
   printf ("<div class='expander_content' id='x_%s'>\n",
-      normalize (babl->instance.name));
+          normalize (babl->instance.name));
 
 
   switch (babl->class_type)
@@ -142,18 +143,22 @@ each_item (Babl *babl,
       case BABL_TYPE:
         type_html (babl);
         break;
+
       case BABL_MODEL:
         model_html (babl);
         break;
+
       case BABL_FORMAT:
         format_html (babl);
         break;
+
       case BABL_CONVERSION:
       case BABL_CONVERSION_LINEAR:
       case BABL_CONVERSION_PLANE:
       case BABL_CONVERSION_PLANAR:
         conversion_html (babl);
         break;
+
       default:
         break;
     }
@@ -171,10 +176,10 @@ model_html (Babl *babl)
   printf ("<dl>");
   printf ("<dt>components</dt><dd><table class='nopad'>");
 
-  for (i=0; i< babl->model.components; i++)
+  for (i = 0; i < babl->model.components; i++)
     {
       printf ("<tr><td class='type'>%s</td></tr>",
-       BABL(babl->model.component[i])->instance.name  );
+              BABL (babl->model.component[i])->instance.name);
     }
   printf ("</table></dd></dl>");
 }
@@ -200,14 +205,14 @@ format_html (Babl *babl)
 
   printf ("<dl>");
   printf ("<dt>bytes/pixel</dt><dd>%i</dd>", babl->format.bytes_per_pixel);
-  printf ("<dt>model</dt><dd>%s</dd>", BABL(babl->format.model)->instance.name  );
+  printf ("<dt>model</dt><dd>%s</dd>", BABL (babl->format.model)->instance.name);
   printf ("<dt>components</dt><dd><table class='nopad'>");
 
-  for (i=0; i< babl->format.components; i++)
+  for (i = 0; i < babl->format.components; i++)
     {
       printf ("<tr><td class='type'>%s</td><td class='component'>%s</td></tr>",
-       BABL(babl->format.type[i])->instance.name,
-       BABL(babl->format.component[i])->instance.name  );
+              BABL (babl->format.type[i])->instance.name,
+              BABL (babl->format.component[i])->instance.name);
     }
   printf ("</table></dd></dl>");
 }
index 5dca8c7cc968b21986a4f314427802477f18f1d8..2777f8c2422a0ec3085a1e71d784f77925718953 100644 (file)
 #include "babl-internal.h"
 
 struct
-  {
-    long  klass;                          const char *name;
-                       } reference[]= {
-    {BABL_INSTANCE,                       "BablInstance"},
-    {BABL_TYPE,                           "BablType"},
-    {BABL_TYPE_INTEGER,                   "BablTypeInteger"},
-    {BABL_TYPE_FLOAT,                     "BablTypeFloat"},
-    {BABL_SAMPLING,                       "BablSampling"},
-    {BABL_COMPONENT,                      "BablComponent"},
-    {BABL_MODEL,                          "BablModel"},
-    {BABL_FORMAT,                         "BablFormat"},
-    {BABL_CONVERSION,                     "BablConversion"},
-    {BABL_CONVERSION_LINEAR,              "BablConversionLinear"},
-    {BABL_CONVERSION_PLANE,               "BablConversionPlane"},
-    {BABL_CONVERSION_PLANAR,              "BablConversionPlanar"},
-    {BABL_FISH,                           "BablFish"},
-    {BABL_FISH_REFERENCE,                 "BablFishReference"},
-    {BABL_IMAGE,                          "BablImage"},
-    {BABL_SKY,                            "BablSky"},
-    {0, NULL}
-  };
+{
+  long klass;                          const char *name;
+} reference[] = {
+  { BABL_INSTANCE,          "BablInstance"         },
+  { BABL_TYPE,              "BablType"             },
+  { BABL_TYPE_INTEGER,      "BablTypeInteger"      },
+  { BABL_TYPE_FLOAT,        "BablTypeFloat"        },
+  { BABL_SAMPLING,          "BablSampling"         },
+  { BABL_COMPONENT,         "BablComponent"        },
+  { BABL_MODEL,             "BablModel"            },
+  { BABL_FORMAT,            "BablFormat"           },
+  { BABL_CONVERSION,        "BablConversion"       },
+  { BABL_CONVERSION_LINEAR, "BablConversionLinear" },
+  { BABL_CONVERSION_PLANE,  "BablConversionPlane"  },
+  { BABL_CONVERSION_PLANAR, "BablConversionPlanar" },
+  { BABL_FISH,              "BablFish"             },
+  { BABL_FISH_REFERENCE,    "BablFishReference"    },
+  { BABL_IMAGE,             "BablImage"            },
+  { BABL_SKY,               "BablSky"              },
+  { 0,                      NULL                   }
+};
 
 static int
 test (void)
 {
-  int i=0;
-  int OK=1;
+  int i  = 0;
+  int OK = 1;
+
   while (reference[i].klass)
     {
       if (strcmp (reference[i].name, babl_class_name (reference[i].klass)))
         {
-          OK=0;
+          OK = 0;
           babl_log ("'%s'!='%s'\n", reference[i].name, babl_class_name (reference[i].klass));
         }
       i++;
@@ -66,7 +67,7 @@ main (int    argc,
       char **argv)
 {
   babl_init ();
-  if (test())
+  if (test ())
     return -1;
   babl_destroy ();
   return 0;
index 2938f9d68e250383972e7585750721c094220c48..5cc52063a4e45d362a5c52d838a032e05a7402e3 100644 (file)
@@ -5,26 +5,26 @@
 #include <math.h>
 #include "babl-internal.h"
 
-#define pixels  1024
-int total_length=0;
-int total_cost=0;
-int total = 0;
-int ok = 0;
+#define pixels    1024
+int           total_length = 0;
+int           total_cost   = 0;
+int           total        = 0;
+int           ok           = 0;
 
 static double test[pixels * 4];
 
 static void
 test_init (void)
 {
-  int    i;
+  int i;
 
   for (i = 0; i < pixels * 4; i++)
-     test [i] = (double)random () / RAND_MAX;
+    test [i] = (double) random () / RAND_MAX;
 }
 
-static int qux=0;
+static int   qux = 0;
 
-static char *utf8_bar[]={" ","·","▁","▂","▃","▄","▅","▆","▇","█"};
+static char *utf8_bar[] = { " ", "·", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" };
 //static char *utf8_bar[]=  {"!","▁","▃","▅","▇","█","!","!","!"};
 //static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁", };
 //static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"};
@@ -32,11 +32,11 @@ static char *utf8_bar[]={" ","·","▁","▂","▃","▄","▅","▆","▇","█
 static int destination_each (Babl *babl,
                              void *userdata)
 {
-  Babl *source = userdata;
+  Babl *source      = userdata;
   Babl *destination = babl;
 
-  if ((qux++) % babl_formats_count () == qux/ babl_formats_count ())
-     printf (" ");
+  if ((qux++) % babl_formats_count () == qux / babl_formats_count ())
+    printf (" ");
   else
     {
       Babl *temp = babl_fish_path (source, destination);
@@ -46,19 +46,19 @@ static int destination_each (Babl *babl,
           printf ("%s", utf8_bar[temp->fish_path.conversions]);
           total_length += temp->fish_path.conversions;
           total_cost   += temp->fish_path.cost;
-          ok ++;
-          total ++;
+          ok++;
+          total++;
         }
       else
         {
           printf (" ");
-          total ++;
+          total++;
         }
     }
   return 0;
 }
 
-static int source_no=0;
+static int source_no = 0;
 
 static int source_each (Babl *babl,
                         void *userdata)
@@ -78,12 +78,12 @@ int main (void)
   {
     int i;
 
-      for (i=0;i<babl_formats_count ();i++) printf ("|"); printf ("\n");
-      for (i=0;i<babl_formats_count ();i++) if (i/10==0) printf("|"); else printf ("%i", (i/10)%10); printf ("\n");
-     /* for (i=0;i<babl_formats_count ();i++) printf ("│"); printf ("\n");
-      for (i=0;i<babl_formats_count ();i++) if (i/10==0) printf("│"); else printf ("%i", (i/10)%10); printf ("\n");*/
-      for (i=0;i<babl_formats_count ();i++) printf ("%i", (i)%10); printf ("\n");
-    }
+    for (i = 0; i < babl_formats_count (); i++) printf ("|");printf ("\n");
+    for (i = 0; i < babl_formats_count (); i++) if (i / 10 == 0) printf ("|");else printf ("%i", (i / 10) % 10);printf ("\n");
+    /* for (i=0;i<babl_formats_count ();i++) printf ("│"); printf ("\n");
+       for (i=0;i<babl_formats_count ();i++) if (i/10==0) printf("│"); else printf ("%i", (i/10)%10); printf ("\n");*/
+    for (i = 0; i < babl_formats_count (); i++) printf ("%i", (i) % 10);printf ("\n");
+  }
   printf ("total length: %i\n", total_length);
   printf ("total cost  : %i\n", total_cost);
   /*printf ("ok / total : %i %i %f\n", ok, total, (1.0*ok) / total);
index 0883944ee5e9954fa130101a5461e000f660b908..d5f70b65cd099809504adec27e43715301db3849 100644 (file)
@@ -5,15 +5,15 @@
 #include <math.h>
 #include "babl-internal.h"
 
-#define ERROR_TOLERANCE 0.5
+#define ERROR_TOLERANCE    0.5
 
-static int OK=1;
+static int OK = 1;
 
 static int
 each_conversion (Babl *babl,
                  void *userdata)
 {
-  double error = babl->conversion.error; 
+  double error = babl->conversion.error;
 
   if (error >= ERROR_TOLERANCE)
     {
index 89158288459792a6bac2db77dc8a02698aac381b..8967f03a5503c6e77c94b7110fd7c2e0cb373133 100644 (file)
@@ -7,7 +7,7 @@
 
 
 static int format_check (Babl *babl,
-                  void *userdata)
+                         void *userdata)
 {
   babl_log ("%s\tloss: %f", babl->instance.name, babl->format.loss);
   return 0;
@@ -18,7 +18,7 @@ int main (void)
   babl_init ();
 
   babl_set_extender (babl_extension_quiet_log ());
-  babl_format_each (format_check, (void*)1);
+  babl_format_each (format_check, (void *) 1);
 
   babl_destroy ();
 
index 71120b8c19f8a1462d6f6c8abe5aa25459e66191..6e22cebeb25dab626ca90b860bfdedf8d8f6f8cb 100644 (file)
 
 #include "babl-internal.h"
 
-#define PIXELS 5
+#define PIXELS    5
 
-float grayscale_buf [PIXELS]= {-0.1, 0.0, 0.4, 1.0, 2.0};
+float grayscale_buf [PIXELS] = { -0.1, 0.0, 0.4, 1.0, 2.0 };
 
-float rgb_buf_ref [PIXELS*3]=
-{ -0.1, -0.1, -0.1, 0.0, 0.0, 0.0, 0.4, 0.4, 0.4, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 }; 
+float rgb_buf_ref [PIXELS * 3] =
+{ -0.1, -0.1, -0.1, 0.0, 0.0, 0.0, 0.4, 0.4, 0.4, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
 
-float rgb_buf     [PIXELS*3];
+float rgb_buf     [PIXELS * 3];
 
 static int
 test (void)
 {
   Babl *fish;
   int   i;
-  int   OK=1;
+  int   OK = 1;
+
 
-  
   fish = babl_fish (
     babl_format_new (
       babl_model ("Y"),
@@ -51,18 +51,18 @@ test (void)
       babl_component ("B"),
       NULL
     )
-  );
+         );
+
+  babl_process (fish,
+                grayscale_buf, rgb_buf,
+                PIXELS);
 
-  babl_process (fish, 
-     grayscale_buf, rgb_buf, 
-     PIXELS);
-  
-  for (i=0; i<PIXELS * 3; i++)
+  for (i = 0; i < PIXELS * 3; i++)
     {
       if (rgb_buf[i] != rgb_buf_ref[i])
         {
           babl_log ("index %i is problematic", i);
-          OK=0;
+          OK = 0;
         }
     }
   if (!OK)
@@ -75,7 +75,7 @@ main (int    argc,
       char **argv)
 {
   babl_init ();
-  if (test())
+  if (test ())
     return -1;
   babl_destroy ();
   return 0;
index 23c37517bc7274938eaa773450a2b74048dacdd9..f4bef9e1219abed1f5dcc8506bcb9a4a280fe34d 100644 (file)
@@ -5,7 +5,7 @@
 #include <math.h>
 #include "babl-internal.h"
 
-int OK=1;
+int OK = 1;
 
 
 static int model_check (Babl *babl,
@@ -14,7 +14,7 @@ static int model_check (Babl *babl,
   if (!babl_model_is_symmetric (babl))
     {
       babl_log ("%s is not symmetric", babl->instance.name);
-      OK=0;
+      OK = 0;
     }
   return 0;
 }
index eb9460c748fcffe2010810c149affcd225bc41cf..99c08f1c4e0048a4a8810a4ec3f41e1bca775bf1 100644 (file)
 #include <math.h>
 #include "babl-internal.h"
 
-#define PIXELS    3
-#define TOLERANCE 0
+#define PIXELS       3
+#define TOLERANCE    0
 
-unsigned char source_buf [PIXELS*3]=
-  {10,20,30,
-   30,30,30,
-   40,50,60};
+unsigned char source_buf [PIXELS * 3] =
+{ 10,   20, 30,
+  30, 30, 30,
+  40, 50, 60 };
 
-unsigned char reference_buf [PIXELS*3]=
-  {30,20,10,
-   30,30,30,
-   60,50,40};
+unsigned char reference_buf [PIXELS * 3] =
+{ 30,   20, 10,
+  30, 30, 30,
+  60, 50, 40 };
 
-unsigned char destination_buf [PIXELS*3];
+unsigned char destination_buf [PIXELS * 3];
 
 static int
 test (void)
 {
   Babl *fish;
   int   i;
-  int   OK=1;
-  
+  int   OK = 1;
+
   fish = babl_fish (
     babl_format_new (
       babl_model ("RGB"),
@@ -60,17 +60,17 @@ test (void)
       babl_component ("R"),
       NULL
     )
-  );
+         );
 
   babl_process (fish, source_buf, destination_buf, PIXELS);
-  
-  for (i=0; i<PIXELS * 3; i++)
+
+  for (i = 0; i < PIXELS * 3; i++)
     {
-      if (abs(destination_buf[i] - reference_buf[i]) > TOLERANCE)
+      if (abs (destination_buf[i] - reference_buf[i]) > TOLERANCE)
         {
           babl_log ("%2i (%2i%%3=%i, %2i/3=%i) is %i should be %i",
-                      i, i,i%3,    i,i/3,  destination_buf[i], reference_buf[i]);
-          OK=0;
+                    i, i, i % 3, i, i / 3, destination_buf[i], reference_buf[i]);
+          OK = 0;
         }
     }
   if (!OK)
@@ -83,7 +83,7 @@ main (int    argc,
       char **argv)
 {
   babl_init ();
-  if (test())
+  if (test ())
     return -1;
   babl_destroy ();
   return 0;
index 8e07a8ab46e99ac141bb5e835ff9b6578d31636a..771430b750a37dd823063fb4ce105aa320206a2e 100644 (file)
 #include <math.h>
 #include "babl-internal.h"
 
-#define PIXELS 6
-#define TOLERANCE 0.000001
+#define PIXELS       6
+#define TOLERANCE    0.000001
 
-float source_buf [PIXELS*3]=
-  {0.0, 0.0, 0.0,
-   0.5, 0.5, 0.5,
-   1.0, 1.0, 1.0,
-   1.0, 0.0, 0.0,
-   0.0, 1.0, 0.0,
-   0.0, 0.0, 1.0};
+float source_buf [PIXELS * 3] =
+{ 0.0,   0.0, 0.0,
+  0.5, 0.5, 0.5,
+  1.0, 1.0, 1.0,
+  1.0, 0.0, 0.0,
+  0.0, 1.0, 0.0,
+  0.0, 0.0, 1.0 };
 
-float reference_buf [PIXELS*3]=
-  {0.0,       0.0,       0.0,
-   0.735357,  0.0,       0.0,
-   1.0,       0.0,       0.0,
-   0.299,    -0.168736,  0.5,
-   0.587,    -0.331264, -0.418688,
-   0.114,     0.5,      -0.081312};
+float reference_buf [PIXELS * 3] =
+{ 0.0,        0.0,       0.0,
+  0.735357, 0.0,       0.0,
+  1.0,      0.0,       0.0,
+  0.299,    -0.168736, 0.5,
+  0.587,    -0.331264, -0.418688,
+  0.114,    0.5,       -0.081312 };
 
 
-float destination_buf [PIXELS*3];
+float destination_buf [PIXELS * 3];
 
 static int
 test (void)
 {
   Babl *fish;
   int   i;
-  int   OK=1;
-  
+  int   OK = 1;
+
   fish = babl_fish (
     babl_format_new (
       babl_model ("RGB"),
@@ -67,17 +67,17 @@ test (void)
       babl_component ("Cr"),
       NULL
     )
-  );
+         );
 
   babl_process (fish, source_buf, destination_buf, PIXELS);
-  
-  for (i=0; i<PIXELS * 3; i++)
+
+  for (i = 0; i < PIXELS * 3; i++)
     {
-      if (fabs(destination_buf[i] - reference_buf[i]) > TOLERANCE)
+      if (fabs (destination_buf[i] - reference_buf[i]) > TOLERANCE)
         {
           babl_log ("%2i (%2i%%3=%i, %2i/3=%i) is %f should be %f",
-                      i, i,i%3,    i,i/3,  destination_buf[i], reference_buf[i]);
-          OK=0;
+                    i, i, i % 3, i, i / 3, destination_buf[i], reference_buf[i]);
+          OK = 0;
         }
     }
   if (!OK)
@@ -90,7 +90,7 @@ main (int    argc,
       char **argv)
 {
   babl_init ();
-  if (test())
+  if (test ())
     return -1;
   babl_destroy ();
   return 0;
index de6da2aa9f00a22e7479d01497ed8dc94a75bd81..d67c894c79d68c5a56f380c794d6d8da917c05bf 100644 (file)
 #include <math.h>
 #include "babl-internal.h"
 
-#define PIXELS    6
-#define TOLERANCE 0
+#define PIXELS       6
+#define TOLERANCE    0
 
-unsigned char source_buf [PIXELS*3]=
-  {  0,   0,   0,
-   127, 127, 127,
-   255, 255, 255,
-   255, 0.0, 0.0,
-   0.0, 255, 0.0,
-   0.0, 0.0, 255};
+unsigned char source_buf [PIXELS * 3] =
+{ 0,     0,   0,
+  127, 127, 127,
+  255, 255, 255,
+  255, 0.0, 0.0,
+  0.0, 255, 0.0,
+  0.0, 0.0, 255 };
 
-unsigned char reference_buf [PIXELS*3]=
-  {  0, 128, 128,
-   136, 128, 128,
-   255, 128, 128,
-   136, 208, 195,
-   224,  42, 211,
-    82, 207,  20};
+unsigned char reference_buf [PIXELS * 3] =
+{ 0,     128, 128,
+  136, 128, 128,
+  255, 128, 128,
+  136, 208, 195,
+  224, 42,  211,
+  82,  207, 20 };
 
-unsigned char destination_buf [PIXELS*3];
+unsigned char destination_buf [PIXELS * 3];
 
 static int
 test (void)
 {
-  int   i;
-  int   OK=1;
+  int i;
+  int OK = 1;
+
   babl_process (babl_fish ("R'G'B' u8", "CIE Lab u8"),
                 source_buf, destination_buf,
                 PIXELS);
-  
-  for (i=0; i<PIXELS * 3; i++)
+
+  for (i = 0; i < PIXELS * 3; i++)
     {
-      if (abs(destination_buf[i] - reference_buf[i]) > TOLERANCE)
+      if (abs (destination_buf[i] - reference_buf[i]) > TOLERANCE)
         {
           babl_log ("%2i (%2i%%3=%i, %2i/3=%i) is %i should be %i",
-                      i, i,i%3,    i,i/3,  destination_buf[i], reference_buf[i]);
-          OK=0;
+                    i, i, i % 3, i, i / 3, destination_buf[i], reference_buf[i]);
+          OK = 0;
         }
     }
   if (!OK)
@@ -70,7 +70,7 @@ main (int    argc,
       char **argv)
 {
   babl_init ();
-  if (test())
+  if (test ())
     return -1;
   babl_destroy ();
   return 0;
index fe99fea2240beebf5af7cf5327d843e2989a69e9..5463fb12e6f73388693b93e4c1df26d6dfd93299 100644 (file)
@@ -1,7 +1,7 @@
 #include <math.h>
 #include "babl-internal.h"
 
-int OK=1;
+int OK = 1;
 
 static int type_check (Babl *babl,
                        void *userdata)
@@ -9,7 +9,7 @@ static int type_check (Babl *babl,
   if (!babl_type_is_symmetric (babl))
     {
       babl_log ("%s is not symmetric", babl->instance.name);
-      OK=0;
+      OK = 0;
     }
   return 0;
 }